summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2022-01-10 01:12:57 +0900
committergit <svn-admin@ruby-lang.org>2023-03-28 02:12:21 +0000
commit9c687c65ee177f0bb160dbcb090bfcc5f59620f1 (patch)
tree754e1f6730deed017cca537e9c3eb1871be8185d
parent708c4903e1a41decd39f3ac95f786f15d942982d (diff)
[ruby/uri] Test for quadratic backtracking on invalid URI
https://hackerone.com/reports/1444501 https://github.com/ruby/uri/commit/54abaa739b
-rw-r--r--test/uri/test_common.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/uri/test_common.rb b/test/uri/test_common.rb
index 038f483a83..245b3d8cc3 100644
--- a/test/uri/test_common.rb
+++ b/test/uri/test_common.rb
@@ -112,6 +112,17 @@ class TestCommon < Test::Unit::TestCase
assert_raise(NoMethodError) { Object.new.URI("http://www.ruby-lang.org/") }
end
+ def test_parse_timeout
+ pre = ->(n) {
+ 'https://example.com/dir/' + 'a' * (n * 100) + '/##.jpg'
+ }
+ assert_linear_performance((1..10).map {|i| i * 100}, pre: pre) do |uri|
+ assert_raise(URI::InvalidURIError) do
+ URI.parse(uri)
+ end
+ end
+ end
+
def test_encode_www_form_component
assert_equal("%00+%21%22%23%24%25%26%27%28%29*%2B%2C-.%2F09%3A%3B%3C%3D%3E%3F%40" \
"AZ%5B%5C%5D%5E_%60az%7B%7C%7D%7E",