Fixes #12698 - Insufficient URL validation Smart Proxy and Medium.
Problem: The regex that validates smart proxies URLs only matches 'beginning of text'. This allows us to add just \n after a valid URL and put anything after it. For instance, javascript:alert('hacked'). I haven't found any link to the Foreman proxy URL so the script would not trigger, but if we were to put link_to @smart_proxy.url somewhere (or a plugin did this) it would be unsafe. Same problem occurrs on Medium path.
Solution: Make the regex match the end of the URL with \Z. I substituted the regex by an standard one, URI.regexp so we don't have to maintain it anymore.
Extra: I added one test for this, but other tests have been rearranged to use stubs rather than building actual SmartProxy objects & associations.
Related issues
Bug #12698: Insufficient URL validation for smart proxy and medium
Fixes #12698 - Insufficient URL validation Smart Proxy and Medium.
Problem: The regex that validates smart proxies URLs only matches
'beginning of text'. This allows us to add just \n after a valid URL and
put anything after it. For instance, javascript:alert('hacked'). I
haven't found any link to the Foreman proxy URL so the script would not
trigger, but if we were to put link_to @smart_proxy.url somewhere (or a
plugin did this) it would be unsafe. Same problem occurrs on Medium
path.
Solution: Make the regex match the end of the URL with \Z. I substituted
the regex by an standard one, URI.regexp so we don't have to maintain it
anymore.
Extra: I added one test for this, but other tests have been rearranged
to use stubs rather than building actual SmartProxy objects &
associations.