summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2022-11-29 16:22:15 +0900
committergit <svn-admin@ruby-lang.org>2023-03-30 10:44:37 +0000
commit623027bf0b5ea8924bb0a680f8e1ddde5116a5df (patch)
treeb4aa4ef3ae239689bd7a16d41aa282ebff8db6ba
parentf5b824c745782d02b9420f8626f633e3de748d73 (diff)
[ruby/time] Test for quadratic backtracking on invalid time
https://hackerone.com/reports/1485501 https://github.com/ruby/time/commit/b30b7bc6e6
-rw-r--r--test/test_time.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/test_time.rb b/test/test_time.rb
index b50d8417cf..23e8e104a1 100644
--- a/test/test_time.rb
+++ b/test/test_time.rb
@@ -62,6 +62,15 @@ class TestTimeExtension < Test::Unit::TestCase # :nodoc:
assert_equal(true, t.utc?)
end
+ def test_rfc2822_nonlinear
+ pre = ->(n) {"0 Feb 00 00 :00" + " " * n}
+ assert_linear_performance([100, 500, 5000, 50_000], pre: pre) do |s|
+ assert_raise(ArgumentError) do
+ Time.rfc2822(s)
+ end
+ end
+ end
+
if defined?(Ractor)
def test_rfc2822_ractor
assert_ractor(<<~RUBY, require: 'time')