ruby-changes:34412
From: naruse <ko1@a...>
Date: Sun, 22 Jun 2014 09:23:58 +0900 (JST)
Subject: [ruby-changes:34412] naruse:r46493 (trunk): * lib/uri/rfc3986_parser.rb: raise exception when given a URI string has non ASCII.
naruse 2014-06-22 09:23:52 +0900 (Sun, 22 Jun 2014) New Revision: 46493 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=46493 Log: * lib/uri/rfc3986_parser.rb: raise exception when given a URI string has non ASCII. It is to keep the regexp compiled for US-ASCII. Modified files: trunk/ChangeLog trunk/lib/uri/rfc3986_parser.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 46492) +++ ChangeLog (revision 46493) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sun Jun 22 09:10:09 2014 NARUSE, Yui <naruse@r...> + + * lib/uri/rfc3986_parser.rb: raise exception when given a URI string + has non ASCII in order to keep the regexp compiled for US-ASCII. + Sun Jun 22 09:05:42 2014 NARUSE, Yui <naruse@r...> * lib/uri/common.rb (URI::REGEXP): move to lib/uri/rfc2396_parser.rb. Index: lib/uri/rfc3986_parser.rb =================================================================== --- lib/uri/rfc3986_parser.rb (revision 46492) +++ lib/uri/rfc3986_parser.rb (revision 46493) @@ -6,6 +6,10 @@ module URI https://github.com/ruby/ruby/blob/trunk/lib/uri/rfc3986_parser.rb#L6 RFC3986_relative_ref = /\A(?<relative-ref>(?<relative-part>\/\/(?<authority>(?:(?<userinfo>(?:%\h\h|[!$&-.0-;=A-Z_a-z~])*)@)?(?<host>(?<IP-literal>\[(?<IPv6address>(?:\h{1,4}:){6}(?<ls32>\h{1,4}:\h{1,4}|(?<IPv4address>(?<dec-octet>[1-9]\d|1\d{2}|2[0-4]\d|25[0-5]|\d)\.\g<dec-octet>\.\g<dec-octet>\.\g<dec-octet>))|::(?:\h{1,4}:){5}\g<ls32>|\h{1,4}?::(?:\h{1,4}:){4}\g<ls32>|(?:(?:\h{1,4}:){,1}\h{1,4})?::(?:\h{1,4}:){3}\g<ls32>|(?:(?:\h{1,4}:){,2}\h{1,4})?::(?:\h{1,4}:){2}\g<ls32>|(?:(?:\h{1,4}:){,3}\h{1,4})?::\h{1,4}:\g<ls32>|(?:(?:\h{1,4}:){,4}\h{1,4})?::\g<ls32>|(?:(?:\h{1,4}:){,5}\h{1,4})?::\h{1,4}|(?:(?:\h{1,4}:){,6}\h{1,4})?::)|(?<IPvFuture>v\h+\.[!$&-.0-;=A-Z_a-z~]+)\])|\g<IPv4address>|(?<reg-name>(?:%\h\h|[!$&-.0-9;=A-Z_a-z~])+))?(?::(?<port>\d*))?)(?<path-abempty>(?:\/(?<segment>(?:%\h\h|[!$&-.0-;=@-Z_a-z~])*))*)|(?<path-absolute>\/(?:(?<segment-nz>(?:%\h\h|[!$&-.0-;=@-Z_a-z~])+)(?:\/\g<segment>)*)?)|(?<path-noscheme>(?<segment-nz-nc>(?:%\h\h|[!$&-.0-9;=@-Z_a-z~])+) (?:\/\g<segment>)*)|(?<path-empty>(?:%\h\h|[!$&-.0-;=@-Z_a-z~]){0}))(?:\?(?<query>(?:%\h\h|[!$&-.0-;=@-Z_a-z~]|[\/?])*))?(?:\#(?<fragment>(?:%\h\h|[!$&-.0-;=@-Z_a-z~]|[\/?])*))?)\z/ def split(uri) #:nodoc: + uri = uri.to_str + unless uri.ascii_only? + raise InvalidURIError, "URI must be ascii only #{uri.dump}" + end if m = RFC3986_URI.match(uri) ary = [] ary << m["scheme"] -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/