Actions
Bug #6520
closedInvalid url is identified as valid
Description
(({
1.9.3p125 :006 > require 'uri'
=> true
1.9.3p125 :007 > URI.parse invalid_url
URI::InvalidURIError: bad URI(is not URI?): http://abc</option%3E
1.9.3p125 :009 > invalid_url =~ URI::regexp
=> 0
}))
As you can see, 'parse' behaves correctly (ie raises an exception), while the 'regexp' does not catch the error
Updated by mame (Yusuke Endoh) over 12 years ago
- Status changed from Open to Rejected
The following will tell you what is happening.
1.9.3p125 :010 > s[URI.regexp]
=> "http://abc"
URI.regexp is supposed to be used to extract urls from text.
str.scan(URI.regexp) { p $& }
I don't think it is a good idea to use this feature to validate a uri string.
--
Yusuke Endoh mame@tsg.ne.jp
Actions
Like0
Like0