aboutsummaryrefslogtreecommitdiffstats
path: root/app/helpers/link_to_helper.rb
diff options
context:
space:
mode:
authorSeb Bacon <seb.bacon@gmail.com>2012-01-11 09:24:36 +0000
committerSeb Bacon <seb.bacon@gmail.com>2012-01-11 09:24:36 +0000
commite7b2e867ff93b4d1daf04b829393ec7d50a27369 (patch)
treef3a5f3846b998f9ade1157b95462591c02d96871 /app/helpers/link_to_helper.rb
parent4e8307fe7bd88b6cdd9840a94f8275354aae0bd8 (diff)
Don't choke on unescaped characters in URIs. Fixes #335.
Diffstat (limited to 'app/helpers/link_to_helper.rb')
-rwxr-xr-xapp/helpers/link_to_helper.rb12
1 files changed, 8 insertions, 4 deletions
diff --git a/app/helpers/link_to_helper.rb b/app/helpers/link_to_helper.rb
index 5866c31f0..7903dee2a 100755
--- a/app/helpers/link_to_helper.rb
+++ b/app/helpers/link_to_helper.rb
@@ -189,10 +189,14 @@ module LinkToHelper
url_prefix = "http://" + MySociety::Config.get("DOMAIN", '127.0.0.1:3000')
url = url_prefix + relative_path
if !append.nil?
- env = Rack::MockRequest.env_for(url)
- req = Rack::Request.new(env)
- req.path_info += append
- url = req.url
+ begin
+ env = Rack::MockRequest.env_for(url)
+ req = Rack::Request.new(env)
+ req.path_info += append
+ url = req.url
+ rescue URI::InvalidURIError
+ # don't append to it
+ end
end
return url
end