-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
(PA-5638) Update Ruby URI gem
- Loading branch information
Showing
4 changed files
with
146 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
diff --git a/lib/uri/rfc2396_parser.rb b/lib/uri/rfc2396_parser.rb | ||
index 76a8f99fd4..00c66cf042 100644 | ||
--- a/lib/uri/rfc2396_parser.rb | ||
+++ b/lib/uri/rfc2396_parser.rb | ||
@@ -497,8 +497,8 @@ def initialize_regexp(pattern) | ||
ret = {} | ||
|
||
# for URI::split | ||
- ret[:ABS_URI] = Regexp.new('\A\s*' + pattern[:X_ABS_URI] + '\s*\z', Regexp::EXTENDED) | ||
- ret[:REL_URI] = Regexp.new('\A\s*' + pattern[:X_REL_URI] + '\s*\z', Regexp::EXTENDED) | ||
+ ret[:ABS_URI] = Regexp.new('\A\s*+' + pattern[:X_ABS_URI] + '\s*\z', Regexp::EXTENDED) | ||
+ ret[:REL_URI] = Regexp.new('\A\s*+' + pattern[:X_REL_URI] + '\s*\z', Regexp::EXTENDED) | ||
|
||
# for URI::extract | ||
ret[:URI_REF] = Regexp.new(pattern[:URI_REF]) | ||
diff --git a/lib/uri/rfc3986_parser.rb b/lib/uri/rfc3986_parser.rb | ||
index dd24a409ea..9b1663dbb6 100644 | ||
--- a/lib/uri/rfc3986_parser.rb | ||
+++ b/lib/uri/rfc3986_parser.rb | ||
@@ -100,7 +100,7 @@ def default_regexp # :nodoc: | ||
QUERY: /\A(?:%\h\h|[!$&-.0-;=@-Z_a-z~\/?])*\z/, | ||
FRAGMENT: /\A(?:%\h\h|[!$&-.0-;=@-Z_a-z~\/?])*\z/, | ||
OPAQUE: /\A(?:[^\/].*)?\z/, | ||
- PORT: /\A[\x09\x0a\x0c\x0d ]*\d*[\x09\x0a\x0c\x0d ]*\z/, | ||
+ PORT: /\A[\x09\x0a\x0c\x0d ]*+\d*[\x09\x0a\x0c\x0d ]*\z/, | ||
} | ||
end | ||
|
||
diff --git a/test/uri/test_parser.rb b/test/uri/test_parser.rb | ||
index 72fb5901d9..cee0acb4b5 100644 | ||
--- a/test/uri/test_parser.rb | ||
+++ b/test/uri/test_parser.rb | ||
@@ -79,4 +79,26 @@ def test_split | ||
assert_equal([nil, nil, "example.com", nil, nil, "", nil, nil, nil], URI.split("//example.com")) | ||
assert_equal([nil, nil, "[0::0]", nil, nil, "", nil, nil, nil], URI.split("//[0::0]")) | ||
end | ||
+ | ||
+ def test_rfc2822_parse_relative_uri | ||
+ pre = ->(length) { | ||
+ " " * length + "\0" | ||
+ } | ||
+ parser = URI::RFC2396_Parser.new | ||
+ assert_linear_performance((1..5).map {|i| 10**i}, pre: pre) do |uri| | ||
+ assert_raise(URI::InvalidURIError) do | ||
+ parser.split(uri) | ||
+ end | ||
+ end | ||
+ end | ||
+ | ||
+ def test_rfc3986_port_check | ||
+ pre = ->(length) {"\t" * length + "a"} | ||
+ uri = URI.parse("http://my.example.com") | ||
+ assert_linear_performance((1..5).map {|i| 10**i}, pre: pre) do |port| | ||
+ assert_raise(URI::InvalidComponentError) do | ||
+ uri.port = port | ||
+ end | ||
+ end | ||
+ end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
From dd73fe077cae077808e820f4765a12b1f4660521 Mon Sep 17 00:00:00 2001 | ||
From: Hiroshi SHIBATA <[email protected]> | ||
Date: Wed, 21 Jun 2023 13:20:54 +0900 | ||
Subject: [PATCH] Merge URI-0.12.2 | ||
|
||
--- | ||
lib/uri/rfc2396_parser.rb | 4 ++-- | ||
lib/uri/rfc3986_parser.rb | 2 +- | ||
lib/uri/version.rb | 2 +- | ||
test/uri/test_parser.rb | 22 ++++++++++++++++++++++ | ||
4 files changed, 26 insertions(+), 4 deletions(-) | ||
|
||
diff --git a/lib/uri/rfc2396_parser.rb b/lib/uri/rfc2396_parser.rb | ||
index 76a8f99fd4..00c66cf042 100644 | ||
--- a/lib/uri/rfc2396_parser.rb | ||
+++ b/lib/uri/rfc2396_parser.rb | ||
@@ -497,8 +497,8 @@ def initialize_regexp(pattern) | ||
ret = {} | ||
|
||
# for URI::split | ||
- ret[:ABS_URI] = Regexp.new('\A\s*' + pattern[:X_ABS_URI] + '\s*\z', Regexp::EXTENDED) | ||
- ret[:REL_URI] = Regexp.new('\A\s*' + pattern[:X_REL_URI] + '\s*\z', Regexp::EXTENDED) | ||
+ ret[:ABS_URI] = Regexp.new('\A\s*+' + pattern[:X_ABS_URI] + '\s*\z', Regexp::EXTENDED) | ||
+ ret[:REL_URI] = Regexp.new('\A\s*+' + pattern[:X_REL_URI] + '\s*\z', Regexp::EXTENDED) | ||
|
||
# for URI::extract | ||
ret[:URI_REF] = Regexp.new(pattern[:URI_REF]) | ||
diff --git a/lib/uri/rfc3986_parser.rb b/lib/uri/rfc3986_parser.rb | ||
index dd24a409ea..9b1663dbb6 100644 | ||
--- a/lib/uri/rfc3986_parser.rb | ||
+++ b/lib/uri/rfc3986_parser.rb | ||
@@ -100,7 +100,7 @@ def default_regexp # :nodoc: | ||
QUERY: /\A(?:%\h\h|[!$&-.0-;=@-Z_a-z~\/?])*\z/, | ||
FRAGMENT: /\A(?:%\h\h|[!$&-.0-;=@-Z_a-z~\/?])*\z/, | ||
OPAQUE: /\A(?:[^\/].*)?\z/, | ||
- PORT: /\A[\x09\x0a\x0c\x0d ]*\d*[\x09\x0a\x0c\x0d ]*\z/, | ||
+ PORT: /\A[\x09\x0a\x0c\x0d ]*+\d*[\x09\x0a\x0c\x0d ]*\z/, | ||
} | ||
end | ||
|
||
diff --git a/lib/uri/version.rb b/lib/uri/version.rb | ||
index 7497a7d31a..f0aca586ac 100644 | ||
--- a/lib/uri/version.rb | ||
+++ b/lib/uri/version.rb | ||
@@ -1,6 +1,6 @@ | ||
module URI | ||
# :stopdoc: | ||
- VERSION_CODE = '001201'.freeze | ||
+ VERSION_CODE = '001202'.freeze | ||
VERSION = VERSION_CODE.scan(/../).collect{|n| n.to_i}.join('.').freeze | ||
# :startdoc: | ||
end | ||
diff --git a/test/uri/test_parser.rb b/test/uri/test_parser.rb | ||
index 72fb5901d9..cee0acb4b5 100644 | ||
--- a/test/uri/test_parser.rb | ||
+++ b/test/uri/test_parser.rb | ||
@@ -79,4 +79,26 @@ def test_split | ||
assert_equal([nil, nil, "example.com", nil, nil, "", nil, nil, nil], URI.split("//example.com")) | ||
assert_equal([nil, nil, "[0::0]", nil, nil, "", nil, nil, nil], URI.split("//[0::0]")) | ||
end | ||
+ | ||
+ def test_rfc2822_parse_relative_uri | ||
+ pre = ->(length) { | ||
+ " " * length + "\0" | ||
+ } | ||
+ parser = URI::RFC2396_Parser.new | ||
+ assert_linear_performance((1..5).map {|i| 10**i}, pre: pre) do |uri| | ||
+ assert_raise(URI::InvalidURIError) do | ||
+ parser.split(uri) | ||
+ end | ||
+ end | ||
+ end | ||
+ | ||
+ def test_rfc3986_port_check | ||
+ pre = ->(length) {"\t" * length + "a"} | ||
+ uri = URI.parse("http://my.example.com") | ||
+ assert_linear_performance((1..5).map {|i| 10**i}, pre: pre) do |port| | ||
+ assert_raise(URI::InvalidComponentError) do | ||
+ uri.port = port | ||
+ end | ||
+ end | ||
+ end | ||
end |