diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-12-06 00:19:28 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-12-06 00:19:28 +0000 |
commit | 2a35a782abac006df0d20e0d93cac3b0e3b568ad (patch) | |
tree | c5ef8b8231c0e4acc6819aa2f2de8c12f1af3a28 /lib/uri/common.rb | |
parent | e959e9f34acb696da9dc42c1bdd962b5fd66ba35 (diff) |
* lib/uri/common.rb (URI::Parser#initialize_pattern):
workaround fix pattern of hostname for RFC 3986. [ruby-dev:42672]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30089 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/uri/common.rb')
-rw-r--r-- | lib/uri/common.rb | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/uri/common.rb b/lib/uri/common.rb index 719dbca4b8..0ffd6ddcc4 100644 --- a/lib/uri/common.rb +++ b/lib/uri/common.rb @@ -31,7 +31,7 @@ module URI # mark = "-" | "_" | "." | "!" | "~" | "*" | "'" | # "(" | ")" # unreserved = alphanum | mark - UNRESERVED = "-_.!~*'()#{ALNUM}" + UNRESERVED = "\\-_.!~*'()#{ALNUM}" # reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" | # "$" | "," # reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" | @@ -239,8 +239,8 @@ module URI ret[:ESCAPED] = escaped = (opts.delete(:ESCAPED) || PATTERN::ESCAPED) ret[:UNRESERVED] = unreserved = opts.delete(:UNRESERVED) || PATTERN::UNRESERVED ret[:RESERVED] = reserved = opts.delete(:RESERVED) || PATTERN::RESERVED - ret[:DOMLABEL] = domlabel = opts.delete(:DOMLABEL) || PATTERN::DOMLABEL - ret[:TOPLABEL] = toplabel = opts.delete(:TOPLABEL) || PATTERN::TOPLABEL + ret[:DOMLABEL] = opts.delete(:DOMLABEL) || PATTERN::DOMLABEL + ret[:TOPLABEL] = opts.delete(:TOPLABEL) || PATTERN::TOPLABEL ret[:HOSTNAME] = hostname = opts.delete(:HOSTNAME) # RFC 2396 (URI Generic Syntax) @@ -258,8 +258,9 @@ module URI ret[:FRAGMENT] = fragment = "#{uric}*" # hostname = *( domainlabel "." ) toplabel [ "." ] + # reg-name = *( unreserved / pct-encoded / sub-delims ) # RFC3986 unless hostname - ret[:HOSTNAME] = hostname = "(?:#{domlabel}\\.)*#{toplabel}\\.?" + ret[:HOSTNAME] = hostname = "(?:[a-zA-Z0-9\\-._~!$&'()*+,;=]|%\\h\\h)*" end # RFC 2373, APPENDIX B: @@ -326,7 +327,7 @@ module URI ret[:REL_SEGMENT] = rel_segment = "(?:[#{unreserved};@&=+$,]|#{escaped})+" # scheme = alpha *( alpha | digit | "+" | "-" | "." ) - ret[:SCHEME] = scheme = "[#{PATTERN::ALPHA}][-+.#{PATTERN::ALPHA}\\d]*" + ret[:SCHEME] = scheme = "[#{PATTERN::ALPHA}][\\-+.#{PATTERN::ALPHA}\\d]*" # abs_path = "/" path_segments ret[:ABS_PATH] = abs_path = "/#{path_segments}" |