Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to handle URI::InvalidURIError? #78

Closed
PikachuEXE opened this issue Jan 23, 2015 · 7 comments
Closed

How to handle URI::InvalidURIError? #78

PikachuEXE opened this issue Jan 23, 2015 · 7 comments

Comments

@PikachuEXE
Copy link

Caused by any bad URL like http://example.com/<lan

stacktrace:

/usr/lib/ruby/2.1.0/uri/common.rb:176→ split
/usr/lib/ruby/2.1.0/uri/common.rb:712→ split
rack-ssl-enforcer-0.2.8/lib/rack/ssl-enforcer.rb:156→ replace_scheme
rack-ssl-enforcer-0.2.8/lib/rack/ssl-enforcer.rb:92→ modify_location_and_redirect
rack-ssl-enforcer-0.2.8/lib/rack/ssl-enforcer.rb:50→ call
@henrywho
Copy link

henrywho commented Apr 1, 2015

👍

I was running into this issue with urls that have curly braces, like http://example.com/?{}

@fzagarzazu
Copy link

Monkey patching example:

    module Rack
      class SslEnforcer
        alias_method :modify_location_and_redirect_orig, :modify_location_and_redirect
        def modify_location_and_redirect
          modify_location_and_redirect_orig
        rescue URI::InvalidURIError
          body = { status: 400, error: 'Bad Request' }
          [400, { 'Content-Type' => 'application/json' }, [ body.to_json ] ]
        end
      end
    end

@PikachuEXE
Copy link
Author

@fzagarzazu Thanks for your solution!
I implement it to return HTML instead, aligning with the existing behaviour.
See https://github.com/tobmatth/rack-ssl-enforcer/blob/master/lib/rack/ssl-enforcer.rb#L97

@PikachuEXE
Copy link
Author

Can a new version be released?
Last version is released > 6 months ago

@tobmatth
Copy link
Owner

Hey,

sure. I'll release a new version within the next few days after taking a closer look at #79

@toshimaru
Copy link

+1

@tobmatth
Copy link
Owner

tobmatth commented Sep 5, 2015

Hey,

0.2.9 should be available via Rubygems...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants