A platform for community discussion. Free, open, simple.
FIX: Escaped `mailto` URLs would raise an exception
Robin Ward00afd308c11c
diff --git a/lib/url_helper.rb b/lib/url_helper.rbindex 7968c9ab39a..f52b90c3ba1 100644--- a/lib/url_helper.rb+++ b/lib/url_helper.rb@@ -70,7 +70,7 @@ class UrlHelperdef self.rails_route_from_url(url)path = URI.parse(encode(url)).pathRails.application.routes.recognize_path(path)- rescue Addressable::URI::InvalidURIError+ rescue Addressable::URI::InvalidURIError, URI::InvalidComponentErrornilenddiff --git a/spec/components/url_helper_spec.rb b/spec/components/url_helper_spec.rbindex d56efc2b15b..8328cec9b96 100644--- a/spec/components/url_helper_spec.rb+++ b/spec/components/url_helper_spec.rb@@ -205,5 +205,10 @@ describe UrlHelper dourl = "http://URL:%20https://google.com"expect(described_class.rails_route_from_url(url)).to eq(nil)end++ it "does not raise for invalid mailtos" do+ url = "mailto:eviltrout%2540example.com"+ expect(described_class.rails_route_from_url(url)).to eq(nil)+ endendend