From f1764623db38bd5773e741b038f36f9dcd3173f2 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 8 Jul 2025 19:35:06 +0900 Subject: [PATCH] [ruby/uri] Make URI::regexp schemes case sensitive (https://github.com/ruby/uri/pull/38) https://github.com/ruby/uri/commit/0c2b6468fa --- lib/uri/rfc2396_parser.rb | 2 +- test/uri/test_parser.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/uri/rfc2396_parser.rb b/lib/uri/rfc2396_parser.rb index 75a2d2dbde..c6096c49e5 100644 --- a/lib/uri/rfc2396_parser.rb +++ b/lib/uri/rfc2396_parser.rb @@ -263,7 +263,7 @@ module URI unless schemes @regexp[:ABS_URI_REF] else - /(?=#{Regexp.union(*schemes)}:)#{@pattern[:X_ABS_URI]}/x + /(?=(?i:#{Regexp.union(*schemes).source}):)#{@pattern[:X_ABS_URI]}/x end end diff --git a/test/uri/test_parser.rb b/test/uri/test_parser.rb index 04c2cd39be..c14824f5e8 100644 --- a/test/uri/test_parser.rb +++ b/test/uri/test_parser.rb @@ -113,4 +113,12 @@ class URI::TestParser < Test::Unit::TestCase end end end + + def test_rfc2822_make_regexp + parser = URI::RFC2396_Parser.new + regexp = parser.make_regexp("HTTP") + assert_match(regexp, "HTTP://EXAMPLE.COM/") + assert_match(regexp, "http://example.com/") + refute_match(regexp, "https://example.com/") + end end