summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2023-03-30 19:54:12 +0900
committerGitHub <noreply@github.com>2023-03-30 10:54:12 +0000
commit34d5d10517825a51bea6bcb13ead1484c7182b42 (patch)
treede17de0ae3c78544066c25f21a40c7f87eb14257
parent250ff4ff45f1257b395260fe42d914cbb0720a41 (diff)
downloadruby-34d5d10517825a51bea6bcb13ead1484c7182b42.tar.gz
Merge Time-0.2.2 (#7623)
-rw-r--r--lib/time.gemspec2
-rw-r--r--lib/time.rb4
-rw-r--r--test/test_time.rb9
3 files changed, 12 insertions, 3 deletions
diff --git a/lib/time.gemspec b/lib/time.gemspec
index e4b5502f28..bada91a30b 100644
--- a/lib/time.gemspec
+++ b/lib/time.gemspec
@@ -1,6 +1,6 @@
Gem::Specification.new do |spec|
spec.name = "time"
- spec.version = "0.2.1"
+ spec.version = "0.2.2"
spec.authors = ["Tanaka Akira"]
spec.email = ["akr@fsij.org"]
diff --git a/lib/time.rb b/lib/time.rb
index 43c4d802e5..6a13212a49 100644
--- a/lib/time.rb
+++ b/lib/time.rb
@@ -509,8 +509,8 @@ class Time
(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s+
(\d{2,})\s+
(\d{2})\s*
- :\s*(\d{2})\s*
- (?::\s*(\d{2}))?\s+
+ :\s*(\d{2})
+ (?:\s*:\s*(\d\d))?\s+
([+-]\d{4}|
UT|GMT|EST|EDT|CST|CDT|MST|MDT|PST|PDT|[A-IK-Z])/ix =~ date
# Since RFC 2822 permit comments, the regexp has no right anchor.
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')