From: "mame (Yusuke Endoh)" Date: 2012-06-01T01:47:42+09:00 Subject: [ruby-core:45345] [ruby-trunk - Bug #6520][Rejected] Invalid url is identified as valid Issue #6520 has been updated by mame (Yusuke Endoh). 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 ---------------------------------------- Bug #6520: Invalid url is identified as valid https://bugs.ruby-lang.org/issues/6520#change-26932 Author: zheka (Eugene Mirkin) Status: Rejected Priority: Normal Assignee: Category: Target version: ruby -v: 1.9.3p125 (({ 1.9.3p125 :006 > require 'uri' => true 1.9.3p125 :007 > URI.parse invalid_url URI::InvalidURIError: bad URI(is not URI?): http://abc invalid_url =~ URI::regexp => 0 })) As you can see, 'parse' behaves correctly (ie raises an exception), while the 'regexp' does not catch the error -- http://bugs.ruby-lang.org/