From f3fb80c0adb60ce7012c36e5d3714b037a280b06 Mon Sep 17 00:00:00 2001 From: Aleksei Strizhak Date: Sun, 26 Sep 2021 02:09:06 +0500 Subject: [PATCH 01/28] Refactor Addressable::URI.normalize_path, fix linter offenses (#430) - refactor normalize_path method with [loop-with-break](https://github.com/rubocop/ruby-style-guide#loop-with-break) recommendation - refactor normalize_path method with solve may be uninitialized IDE offenses - refactor normalize_path method with solve Style/RedundantReturn: Redundant return detected. --- lib/addressable/uri.rb | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/lib/addressable/uri.rb b/lib/addressable/uri.rb index 2550d9d1..e8d6c429 100644 --- a/lib/addressable/uri.rb +++ b/lib/addressable/uri.rb @@ -2440,30 +2440,35 @@ def defer_validation def self.normalize_path(path) # Section 5.2.4 of RFC 3986 - return nil if path.nil? + return if path.nil? normalized_path = path.dup - begin - mod = nil + loop do mod ||= normalized_path.gsub!(RULE_2A, SLASH) pair = normalized_path.match(RULE_2B_2C) - parent, current = pair[1], pair[2] if pair + if pair + parent = pair[1] + current = pair[2] + else + parent = nil + current = nil + end + + regexp = "/#{Regexp.escape(parent.to_s)}/\\.\\./|" + regexp += "(/#{Regexp.escape(current.to_s)}/\\.\\.$)" + if pair && ((parent != SELF_REF && parent != PARENT) || (current != SELF_REF && current != PARENT)) - mod ||= normalized_path.gsub!( - Regexp.new( - "/#{Regexp.escape(parent.to_s)}/\\.\\./|" + - "(/#{Regexp.escape(current.to_s)}/\\.\\.$)" - ), SLASH - ) + mod ||= normalized_path.gsub!(Regexp.new(regexp), SLASH) end mod ||= normalized_path.gsub!(RULE_2D, EMPTY_STR) # Non-standard, removes prefixed dotted segments from path. mod ||= normalized_path.gsub!(RULE_PREFIXED_PARENT, SLASH) - end until mod.nil? + break if mod.nil? + end - return normalized_path + normalized_path end ## From 4c5857a89b3ad7016ce10cd934d64af844bce375 Mon Sep 17 00:00:00 2001 From: Patrik Ragnarsson Date: Sat, 15 Jan 2022 13:09:56 +0100 Subject: [PATCH 02/28] CI: Add Ruby 3.1 (#450) --- .github/workflows/test.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c653b593..b3bbf490 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -86,6 +86,7 @@ jobs: - 2.7 # quotes because of YAML gotcha: https://github.com/actions/runner/issues/849 - '3.0' + - 3.1 - head - jruby-9.1 - jruby-9.2 @@ -103,6 +104,7 @@ jobs: # Ubuntu 20.04 - { os: ubuntu-20.04, ruby: 2.7 } - { os: ubuntu-20.04, ruby: '3.0' } + - { os: ubuntu-20.04, ruby: 3.1 } # macOS - { os: macos-10.15, ruby: 2.7 } - { os: macos-10.15, ruby: '3.0' } @@ -110,11 +112,13 @@ jobs: - { os: macos-10.15, ruby: truffleruby-21.1 } - { os: macos-11, ruby: 2.7 } - { os: macos-11, ruby: '3.0' } + - { os: macos-11, ruby: 3.1 } - { os: macos-11, ruby: jruby } - { os: macos-11, ruby: truffleruby-21.1 } # Windows - { os: windows-2019, ruby: 2.7 } - { os: windows-2019, ruby: '3.0' } + - { os: windows-2019, ruby: 3.1 } - { os: windows-2019, ruby: jruby-9.1 } - { os: windows-2019, ruby: jruby-9.2 } # allowed to fail From 2e18a2b0d2bbb2368ff8b71cd0a3f2ee3207e176 Mon Sep 17 00:00:00 2001 From: Patrik Ragnarsson Date: Sat, 15 Jan 2022 13:24:45 +0100 Subject: [PATCH 03/28] CI: Add JRuby 9.3 (#451) --- .github/workflows/test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b3bbf490..54e5eefe 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -90,6 +90,7 @@ jobs: - head - jruby-9.1 - jruby-9.2 + - jruby-9.3 - jruby-head # truffleruby-21.2 fails due to https://github.com/oracle/truffleruby/issues/2408 - truffleruby-21.1 @@ -121,6 +122,7 @@ jobs: - { os: windows-2019, ruby: 3.1 } - { os: windows-2019, ruby: jruby-9.1 } - { os: windows-2019, ruby: jruby-9.2 } + - { os: windows-2019, ruby: jruby-9.3 } # allowed to fail - { os: ubuntu-18.04, ruby: jruby-head, allow-failure: true } - { os: ubuntu-18.04, ruby: truffleruby-head, allow-failure: true } From 0e1f9d0e0b5cee26686685d95633af17521b5af0 Mon Sep 17 00:00:00 2001 From: Patrik Ragnarsson Date: Sat, 15 Jan 2022 13:35:44 +0100 Subject: [PATCH 04/28] CI: Use TruffleRuby 21.3 (#452) https://github.com/oracle/truffleruby/issues/2408 was addressed in TruffleRuby 21.3. --- .github/workflows/test.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 54e5eefe..12c50c7b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -92,8 +92,7 @@ jobs: - jruby-9.2 - jruby-9.3 - jruby-head - # truffleruby-21.2 fails due to https://github.com/oracle/truffleruby/issues/2408 - - truffleruby-21.1 + - truffleruby-21.3 - truffleruby-head os: - ubuntu-18.04 @@ -110,12 +109,12 @@ jobs: - { os: macos-10.15, ruby: 2.7 } - { os: macos-10.15, ruby: '3.0' } - { os: macos-10.15, ruby: jruby } - - { os: macos-10.15, ruby: truffleruby-21.1 } + - { os: macos-10.15, ruby: truffleruby-21.3 } - { os: macos-11, ruby: 2.7 } - { os: macos-11, ruby: '3.0' } - { os: macos-11, ruby: 3.1 } - { os: macos-11, ruby: jruby } - - { os: macos-11, ruby: truffleruby-21.1 } + - { os: macos-11, ruby: truffleruby-21.3 } # Windows - { os: windows-2019, ruby: 2.7 } - { os: windows-2019, ruby: '3.0' } From 901e563386c8a0387bd03f908e320b1c171eb59a Mon Sep 17 00:00:00 2001 From: Patrik Ragnarsson Date: Sat, 15 Jan 2022 13:46:29 +0100 Subject: [PATCH 05/28] CI: Add one Windows 2022 job (#453) https://github.blog/changelog/2021-08-23-github-actions-windows-server-2022-with-visual-studio-2022-is-now-available-on-github-hosted-runners-public-beta/ --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 12c50c7b..42aa3131 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -119,6 +119,7 @@ jobs: - { os: windows-2019, ruby: 2.7 } - { os: windows-2019, ruby: '3.0' } - { os: windows-2019, ruby: 3.1 } + - { os: windows-2022, ruby: 3.1 } - { os: windows-2019, ruby: jruby-9.1 } - { os: windows-2019, ruby: jruby-9.2 } - { os: windows-2019, ruby: jruby-9.3 } From dd84176c2ad6c71bbec4b66bfc694d80969149ae Mon Sep 17 00:00:00 2001 From: Dmitry Ukolov Date: Sat, 15 Jan 2022 17:12:51 +0400 Subject: [PATCH 06/28] Remove redundant colon in `CharacterClasses::AUTHORITY` (#438) Co-authored-by: Patrik Ragnarsson --- lib/addressable/uri.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/addressable/uri.rb b/lib/addressable/uri.rb index e8d6c429..b91d513a 100644 --- a/lib/addressable/uri.rb +++ b/lib/addressable/uri.rb @@ -48,7 +48,7 @@ module CharacterClasses PCHAR = UNRESERVED + SUB_DELIMS + "\\:\\@" SCHEME = ALPHA + DIGIT + "\\-\\+\\." HOST = UNRESERVED + SUB_DELIMS + "\\[\\:\\]" - AUTHORITY = PCHAR + "\\[\\:\\]" + AUTHORITY = PCHAR + "\\[\\]" PATH = PCHAR + "\\/" QUERY = PCHAR + "\\/\\?" FRAGMENT = PCHAR + "\\/\\?" From 178bcd97fc77b342a3bda6f5b6e17f8ea344bd51 Mon Sep 17 00:00:00 2001 From: Allison Reid Date: Fri, 14 Jan 2022 19:53:10 -0800 Subject: [PATCH 07/28] Explicitly freeze concatenated-`String` constants to unbreak on non-main `Ractor`s --- lib/addressable/uri.rb | 24 +++++++++++++++--------- spec/addressable/uri_spec.rb | 10 ++++++++++ 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/lib/addressable/uri.rb b/lib/addressable/uri.rb index e8d6c429..9455f81b 100644 --- a/lib/addressable/uri.rb +++ b/lib/addressable/uri.rb @@ -38,20 +38,26 @@ class InvalidURIError < StandardError ## # Container for the character classes specified in # RFC 3986. + # + # Note: Concatenated and interpolated `String`s are not affected by the + # `frozen_string_literal` directive and must be frozen explicitly. + # + # Interpolated `String`s *were* frozen this way before Ruby 3.0: + # https://bugs.ruby-lang.org/issues/17104 module CharacterClasses ALPHA = "a-zA-Z" DIGIT = "0-9" GEN_DELIMS = "\\:\\/\\?\\#\\[\\]\\@" SUB_DELIMS = "\\!\\$\\&\\'\\(\\)\\*\\+\\,\\;\\=" - RESERVED = GEN_DELIMS + SUB_DELIMS - UNRESERVED = ALPHA + DIGIT + "\\-\\.\\_\\~" - PCHAR = UNRESERVED + SUB_DELIMS + "\\:\\@" - SCHEME = ALPHA + DIGIT + "\\-\\+\\." - HOST = UNRESERVED + SUB_DELIMS + "\\[\\:\\]" - AUTHORITY = PCHAR + "\\[\\:\\]" - PATH = PCHAR + "\\/" - QUERY = PCHAR + "\\/\\?" - FRAGMENT = PCHAR + "\\/\\?" + RESERVED = (GEN_DELIMS + SUB_DELIMS).freeze + UNRESERVED = (ALPHA + DIGIT + "\\-\\.\\_\\~").freeze + PCHAR = (UNRESERVED + SUB_DELIMS + "\\:\\@").freeze + SCHEME = (ALPHA + DIGIT + "\\-\\+\\.").freeze + HOST = (UNRESERVED + SUB_DELIMS + "\\[\\:\\]").freeze + AUTHORITY = (PCHAR + "\\[\\:\\]").freeze + PATH = (PCHAR + "\\/").freeze + QUERY = (PCHAR + "\\/\\?").freeze + FRAGMENT = (PCHAR + "\\/\\?").freeze end module NormalizeCharacterClasses diff --git a/spec/addressable/uri_spec.rb b/spec/addressable/uri_spec.rb index 00baaacf..aa3ec7a3 100644 --- a/spec/addressable/uri_spec.rb +++ b/spec/addressable/uri_spec.rb @@ -6663,3 +6663,13 @@ def to_str expect(@uri.class).to eq(@uri.join('path').class) end end + +describe Addressable::URI, "when initialized in a non-main `Ractor`" do + it "should have the same value as if used in the main `Ractor`" do + pending("Ruby 3.0+ for `Ractor` support") unless defined?(Ractor) + main = Addressable::URI.parse("http://example.com") + expect( + Ractor.new { Addressable::URI.parse("http://example.com") }.take + ).to eq(main) + end +end From 5944f88a797800cf31fb96988bea62563e922da8 Mon Sep 17 00:00:00 2001 From: Patrik Ragnarsson Date: Mon, 25 Jul 2022 07:58:45 +0200 Subject: [PATCH 08/28] Make Windows JRuby builds pass (#461) --- .github/workflows/test.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 42aa3131..2da55bdf 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -129,6 +129,10 @@ jobs: env: BUNDLE_GEMFILE: ${{ matrix.gemfile }} BUNDLE_WITHOUT: development:coverage + # Workaround for Windows JRuby JDK issue + # https://github.com/ruby/setup-ruby/issues/339 + # https://github.com/jruby/jruby/issues/7182#issuecomment-1112953015 + JAVA_OPTS: -Djdk.io.File.enableADS=true steps: - uses: actions/checkout@v2 From f4bee658a4920eaaba62b2baf03077dcd4bd2e6c Mon Sep 17 00:00:00 2001 From: Patrik Ragnarsson Date: Mon, 25 Jul 2022 08:52:43 +0200 Subject: [PATCH 09/28] Avoid installing `idn-ruby` if `IDNA_MODE=pure` (#462) Makes it easier to do a quick test in Docker like this $ docker run --rm -it -v $(pwd):/app -w /app ruby:3.1 bash root@caa1b64ea763:/app# BUNDLE_WITHOUT=development:coverage IDNA_MODE=pure bundle ... --- Gemfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 6ebb8b75..0d36ffb5 100644 --- a/Gemfile +++ b/Gemfile @@ -25,4 +25,6 @@ group :test, :development do gem "rake", ">= 12.3.3" end -gem "idn-ruby", platform: :mri +unless ENV["IDNA_MODE"] == "pure" + gem "idn-ruby", platform: :mri +end From d2df5e897afa66deba7764d111a68c3d3fb0f658 Mon Sep 17 00:00:00 2001 From: Peter Goldstein Date: Mon, 25 Jul 2022 03:18:10 -0400 Subject: [PATCH 10/28] Loosen public suffix restriction to allow version 5.0 (#460) public_suffix 5.0 was just released. It includes updated definitions, and is restricted to Ruby 2.6+. Loosening this restriction allows addressable to use the latest version of public_suffix when loaded with a supported Ruby. Co-authored-by: Patrik Ragnarsson --- addressable.gemspec | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addressable.gemspec b/addressable.gemspec index 5a2710c2..648e76ee 100644 --- a/addressable.gemspec +++ b/addressable.gemspec @@ -24,14 +24,14 @@ Gem::Specification.new do |s| s.specification_version = 4 if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then - s.add_runtime_dependency(%q.freeze, [">= 2.0.2", "< 5.0"]) + s.add_runtime_dependency(%q.freeze, [">= 2.0.2", "< 6.0"]) s.add_development_dependency(%q.freeze, [">= 1.0", "< 3.0"]) else - s.add_dependency(%q.freeze, [">= 2.0.2", "< 5.0"]) + s.add_dependency(%q.freeze, [">= 2.0.2", "< 6.0"]) s.add_dependency(%q.freeze, [">= 1.0", "< 3.0"]) end else - s.add_dependency(%q.freeze, [">= 2.0.2", "< 5.0"]) + s.add_dependency(%q.freeze, [">= 2.0.2", "< 6.0"]) s.add_dependency(%q.freeze, [">= 1.0", "< 3.0"]) end end From a8662079214ddaabf9795c207f8724783d858f27 Mon Sep 17 00:00:00 2001 From: Patrik Ragnarsson Date: Mon, 25 Jul 2022 09:36:55 +0200 Subject: [PATCH 11/28] Set required Ruby version to >= 2.2 in gemspec (#463) 892861d (part of #416) dropped support for Ruby 2.0, 2.1. --- addressable.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addressable.gemspec b/addressable.gemspec index 648e76ee..b1f7de70 100644 --- a/addressable.gemspec +++ b/addressable.gemspec @@ -16,7 +16,7 @@ Gem::Specification.new do |s| s.homepage = "https://github.com/sporkmonger/addressable".freeze s.licenses = ["Apache-2.0".freeze] s.rdoc_options = ["--main".freeze, "README.md".freeze] - s.required_ruby_version = Gem::Requirement.new(">= 2.0".freeze) + s.required_ruby_version = Gem::Requirement.new(">= 2.2".freeze) s.rubygems_version = "3.0.3".freeze s.summary = "URI Implementation".freeze From 13f95ee646e1e82491d9defdc125ef49e83cdfe2 Mon Sep 17 00:00:00 2001 From: Patrik Ragnarsson Date: Mon, 25 Jul 2022 10:18:26 +0200 Subject: [PATCH 12/28] Set required Ruby to >= 2.2 in gemspec task (#464) Addressable 2.8.0 (892861d (part of #416)) dropped support for Ruby 2.0, 2.1. Follow-up to #463 --- tasks/gem.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/gem.rake b/tasks/gem.rake index 4d9dee2e..0919afc6 100644 --- a/tasks/gem.rake +++ b/tasks/gem.rake @@ -19,7 +19,7 @@ namespace :gem do exit(1) end - s.required_ruby_version = ">= 2.0" + s.required_ruby_version = ">= 2.2" s.add_runtime_dependency "public_suffix", ">= 2.0.2", "< 5.0" s.add_development_dependency "bundler", ">= 1.0", "< 3.0" From 299372a54630b70fc0421e121e1c920333bee799 Mon Sep 17 00:00:00 2001 From: Patrik Ragnarsson Date: Mon, 25 Jul 2022 11:25:51 +0200 Subject: [PATCH 13/28] Allow use of `public_suffix` 5 (#465) Follow-up to #460 --- tasks/gem.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/gem.rake b/tasks/gem.rake index 0919afc6..24d9714b 100644 --- a/tasks/gem.rake +++ b/tasks/gem.rake @@ -21,7 +21,7 @@ namespace :gem do s.required_ruby_version = ">= 2.2" - s.add_runtime_dependency "public_suffix", ">= 2.0.2", "< 5.0" + s.add_runtime_dependency "public_suffix", ">= 2.0.2", "< 6.0" s.add_development_dependency "bundler", ">= 1.0", "< 3.0" s.require_path = "lib" From 183b6ea38ccffd145e4ddc56707131527d2cce23 Mon Sep 17 00:00:00 2001 From: Patrik Ragnarsson Date: Mon, 25 Jul 2022 14:31:44 +0200 Subject: [PATCH 14/28] Update generated gemspec (#466) I ran "bundle exec rake gem:gemspec" and this is what changed, except the date (did not change the date as I think that should reflect when releases are made). Related to #460 and #463 that both updated the generated gemspec directly. Includes the change from #425. --- addressable.gemspec | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/addressable.gemspec b/addressable.gemspec index b1f7de70..1ee6542e 100644 --- a/addressable.gemspec +++ b/addressable.gemspec @@ -6,30 +6,28 @@ Gem::Specification.new do |s| s.version = "2.8.0" s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version= + s.metadata = { "changelog_uri" => "https://github.com/sporkmonger/addressable/blob/main/CHANGELOG.md" } if s.respond_to? :metadata= s.require_paths = ["lib".freeze] s.authors = ["Bob Aman".freeze] s.date = "2021-07-03" s.description = "Addressable is an alternative implementation to the URI implementation that is\npart of Ruby's standard library. It is flexible, offers heuristic parsing, and\nadditionally provides extensive support for IRIs and URI templates.\n".freeze s.email = "bob@sporkmonger.com".freeze s.extra_rdoc_files = ["README.md".freeze] - s.files = ["CHANGELOG.md".freeze, "Gemfile".freeze, "LICENSE.txt".freeze, "README.md".freeze, "Rakefile".freeze, "addressable.gemspec".freeze, "benchmark".freeze, "coverage".freeze, "data".freeze, "data/unicode.data".freeze, "documentation".freeze, "gemfiles".freeze, "lib".freeze, "lib/addressable".freeze, "lib/addressable.rb".freeze, "lib/addressable/idna".freeze, "lib/addressable/idna.rb".freeze, "lib/addressable/idna/native.rb".freeze, "lib/addressable/idna/pure.rb".freeze, "lib/addressable/template.rb".freeze, "lib/addressable/uri.rb".freeze, "lib/addressable/version.rb".freeze, "spec".freeze, "spec/addressable".freeze, "spec/addressable/idna_spec.rb".freeze, "spec/addressable/net_http_compat_spec.rb".freeze, "spec/addressable/security_spec.rb".freeze, "spec/addressable/template_spec.rb".freeze, "spec/addressable/uri_spec.rb".freeze, "spec/spec_helper.rb".freeze, "specdoc".freeze, "tasks".freeze, "tasks/clobber.rake".freeze, "tasks/gem.rake".freeze, "tasks/git.rake".freeze, "tasks/metrics.rake".freeze, "tasks/profile.rake".freeze, "tasks/rspec.rake".freeze, "tasks/yard.rake".freeze, "tmp".freeze] + s.files = ["CHANGELOG.md".freeze, "Gemfile".freeze, "LICENSE.txt".freeze, "README.md".freeze, "Rakefile".freeze, "data/unicode.data".freeze, "lib/addressable".freeze, "lib/addressable.rb".freeze, "lib/addressable/idna".freeze, "lib/addressable/idna.rb".freeze, "lib/addressable/idna/native.rb".freeze, "lib/addressable/idna/pure.rb".freeze, "lib/addressable/template.rb".freeze, "lib/addressable/uri.rb".freeze, "lib/addressable/version.rb".freeze, "spec/addressable".freeze, "spec/addressable/idna_spec.rb".freeze, "spec/addressable/net_http_compat_spec.rb".freeze, "spec/addressable/security_spec.rb".freeze, "spec/addressable/template_spec.rb".freeze, "spec/addressable/uri_spec.rb".freeze, "spec/spec_helper.rb".freeze, "tasks/clobber.rake".freeze, "tasks/gem.rake".freeze, "tasks/git.rake".freeze, "tasks/metrics.rake".freeze, "tasks/profile.rake".freeze, "tasks/rspec.rake".freeze, "tasks/yard.rake".freeze] s.homepage = "https://github.com/sporkmonger/addressable".freeze s.licenses = ["Apache-2.0".freeze] s.rdoc_options = ["--main".freeze, "README.md".freeze] s.required_ruby_version = Gem::Requirement.new(">= 2.2".freeze) - s.rubygems_version = "3.0.3".freeze + s.rubygems_version = "3.3.7".freeze s.summary = "URI Implementation".freeze if s.respond_to? :specification_version then s.specification_version = 4 + end - if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then - s.add_runtime_dependency(%q.freeze, [">= 2.0.2", "< 6.0"]) - s.add_development_dependency(%q.freeze, [">= 1.0", "< 3.0"]) - else - s.add_dependency(%q.freeze, [">= 2.0.2", "< 6.0"]) - s.add_dependency(%q.freeze, [">= 1.0", "< 3.0"]) - end + if s.respond_to? :add_runtime_dependency then + s.add_runtime_dependency(%q.freeze, [">= 2.0.2", "< 6.0"]) + s.add_development_dependency(%q.freeze, [">= 1.0", "< 3.0"]) else s.add_dependency(%q.freeze, [">= 2.0.2", "< 6.0"]) s.add_dependency(%q.freeze, [">= 1.0", "< 3.0"]) From ab4bc464027d9edc4aee410f20895483b107b3cd Mon Sep 17 00:00:00 2001 From: Patrik Ragnarsson Date: Mon, 25 Jul 2022 18:12:49 +0200 Subject: [PATCH 15/28] Remove all magic comments about encoding (#468) They only work when they are on the first line as pointed out by https://github.com/sporkmonger/addressable/issues/423 (#309 broke that when adding the frozen_string_literal pragma) UTF-8 is the default (as pointed out by our bot in #467), so remove them. Close #423 --- lib/addressable/idna.rb | 1 - lib/addressable/idna/native.rb | 1 - lib/addressable/idna/pure.rb | 1 - lib/addressable/template.rb | 1 - lib/addressable/uri.rb | 1 - lib/addressable/version.rb | 1 - spec/addressable/idna_spec.rb | 1 - spec/addressable/net_http_compat_spec.rb | 1 - spec/addressable/security_spec.rb | 1 - spec/addressable/template_spec.rb | 1 - spec/addressable/uri_spec.rb | 1 - 11 files changed, 11 deletions(-) diff --git a/lib/addressable/idna.rb b/lib/addressable/idna.rb index e41c1f5d..2dbd3934 100644 --- a/lib/addressable/idna.rb +++ b/lib/addressable/idna.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true -# encoding:utf-8 #-- # Copyright (C) Bob Aman # diff --git a/lib/addressable/idna/native.rb b/lib/addressable/idna/native.rb index 84de8e8c..302e1b0c 100644 --- a/lib/addressable/idna/native.rb +++ b/lib/addressable/idna/native.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true -# encoding:utf-8 #-- # Copyright (C) Bob Aman # diff --git a/lib/addressable/idna/pure.rb b/lib/addressable/idna/pure.rb index 7a0c1fda..a7c796e3 100644 --- a/lib/addressable/idna/pure.rb +++ b/lib/addressable/idna/pure.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true -# encoding:utf-8 #-- # Copyright (C) Bob Aman # diff --git a/lib/addressable/template.rb b/lib/addressable/template.rb index 398af17c..232595c1 100644 --- a/lib/addressable/template.rb +++ b/lib/addressable/template.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true -# encoding:utf-8 #-- # Copyright (C) Bob Aman # diff --git a/lib/addressable/uri.rb b/lib/addressable/uri.rb index b91d513a..6e55cda9 100644 --- a/lib/addressable/uri.rb +++ b/lib/addressable/uri.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true -# encoding:utf-8 #-- # Copyright (C) Bob Aman # diff --git a/lib/addressable/version.rb b/lib/addressable/version.rb index 2efe4340..76670295 100644 --- a/lib/addressable/version.rb +++ b/lib/addressable/version.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true -# encoding:utf-8 #-- # Copyright (C) Bob Aman # diff --git a/spec/addressable/idna_spec.rb b/spec/addressable/idna_spec.rb index 4104b370..b1509d22 100644 --- a/spec/addressable/idna_spec.rb +++ b/spec/addressable/idna_spec.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true -# coding: utf-8 # Copyright (C) Bob Aman # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/spec/addressable/net_http_compat_spec.rb b/spec/addressable/net_http_compat_spec.rb index 8663a867..d07a43e5 100644 --- a/spec/addressable/net_http_compat_spec.rb +++ b/spec/addressable/net_http_compat_spec.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true -# coding: utf-8 # Copyright (C) Bob Aman # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/spec/addressable/security_spec.rb b/spec/addressable/security_spec.rb index 601e8088..3bf90a20 100644 --- a/spec/addressable/security_spec.rb +++ b/spec/addressable/security_spec.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true -# coding: utf-8 # Copyright (C) Bob Aman # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/spec/addressable/template_spec.rb b/spec/addressable/template_spec.rb index d47589ab..feaa9bde 100644 --- a/spec/addressable/template_spec.rb +++ b/spec/addressable/template_spec.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true -# coding: utf-8 # Copyright (C) Bob Aman # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/spec/addressable/uri_spec.rb b/spec/addressable/uri_spec.rb index 00baaacf..76edaad0 100644 --- a/spec/addressable/uri_spec.rb +++ b/spec/addressable/uri_spec.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true -# coding: utf-8 # Copyright (C) Bob Aman # # Licensed under the Apache License, Version 2.0 (the "License"); From 180c2b82dcf95a8bcba29772e9fc7498178c5007 Mon Sep 17 00:00:00 2001 From: Patrik Ragnarsson Date: Mon, 25 Jul 2022 18:27:38 +0200 Subject: [PATCH 16/28] Less Windows jobs Test latest Ruby on both Windows versions available, test latest JRuby on latest Windows (don't use the -latest label so we are in control when to switch). --- .github/workflows/test.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2da55bdf..30ccc67b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -116,13 +116,9 @@ jobs: - { os: macos-11, ruby: jruby } - { os: macos-11, ruby: truffleruby-21.3 } # Windows - - { os: windows-2019, ruby: 2.7 } - - { os: windows-2019, ruby: '3.0' } - { os: windows-2019, ruby: 3.1 } - { os: windows-2022, ruby: 3.1 } - - { os: windows-2019, ruby: jruby-9.1 } - - { os: windows-2019, ruby: jruby-9.2 } - - { os: windows-2019, ruby: jruby-9.3 } + - { os: windows-2022, ruby: jruby-9.3 } # allowed to fail - { os: ubuntu-18.04, ruby: jruby-head, allow-failure: true } - { os: ubuntu-18.04, ruby: truffleruby-head, allow-failure: true } From 32e8ab13bd3113f50bfc232db8bf1a5dd8077444 Mon Sep 17 00:00:00 2001 From: Patrik Ragnarsson Date: Mon, 25 Jul 2022 18:30:31 +0200 Subject: [PATCH 17/28] Remove macOS 10.15 jobs "The macOS-10.15 environment is deprecated" warnings are displayed when running these jobs. Will stop working soon: https://github.com/actions/virtual-environments/issues/5583 --- .github/workflows/test.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 30ccc67b..ee5bd302 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -106,10 +106,6 @@ jobs: - { os: ubuntu-20.04, ruby: '3.0' } - { os: ubuntu-20.04, ruby: 3.1 } # macOS - - { os: macos-10.15, ruby: 2.7 } - - { os: macos-10.15, ruby: '3.0' } - - { os: macos-10.15, ruby: jruby } - - { os: macos-10.15, ruby: truffleruby-21.3 } - { os: macos-11, ruby: 2.7 } - { os: macos-11, ruby: '3.0' } - { os: macos-11, ruby: 3.1 } From f0a6225b9f385c14e1d868e3b606807e7255b98b Mon Sep 17 00:00:00 2001 From: Patrik Ragnarsson Date: Mon, 25 Jul 2022 18:31:59 +0200 Subject: [PATCH 18/28] Less macOS jobs (but add macOS 12 job) Only test MRI on macOS, running the JVM based Rubies should be the same everywhere. --- .github/workflows/test.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ee5bd302..2f33c2ce 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -106,11 +106,8 @@ jobs: - { os: ubuntu-20.04, ruby: '3.0' } - { os: ubuntu-20.04, ruby: 3.1 } # macOS - - { os: macos-11, ruby: 2.7 } - - { os: macos-11, ruby: '3.0' } - { os: macos-11, ruby: 3.1 } - - { os: macos-11, ruby: jruby } - - { os: macos-11, ruby: truffleruby-21.3 } + - { os: macos-12, ruby: 3.1 } # Windows - { os: windows-2019, ruby: 3.1 } - { os: windows-2022, ruby: 3.1 } From 112582a5b35f1b3bb4f3d1f334aefc3ef4229b6c Mon Sep 17 00:00:00 2001 From: Patrik Ragnarsson Date: Mon, 25 Jul 2022 18:33:23 +0200 Subject: [PATCH 19/28] Add TruffleRuby 22.1 job https://github.com/oracle/truffleruby/releases/tag/vm-22.1.0 --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2f33c2ce..57c79c32 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -93,6 +93,7 @@ jobs: - jruby-9.3 - jruby-head - truffleruby-21.3 + - truffleruby-22.1 - truffleruby-head os: - ubuntu-18.04 From 254ef6d3b4492e934ce8ba275883e7defa866257 Mon Sep 17 00:00:00 2001 From: Patrik Ragnarsson Date: Mon, 25 Jul 2022 18:37:19 +0200 Subject: [PATCH 20/28] Add Ubuntu 22.04 job, use 20.04 as the default Test oldest non-EoL Ruby on 18.04 and latest on 22.04 (only 3.1 available there anyway, https://github.com/ruby/setup-ruby/tree/v1.111.0#supported-platforms). --- .github/workflows/test.yml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 57c79c32..af55bd56 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -96,16 +96,15 @@ jobs: - truffleruby-22.1 - truffleruby-head os: - - ubuntu-18.04 + - ubuntu-20.04 gemfile: - Gemfile include: - - { os: ubuntu-18.04, ruby: 2.7, gemfile: gemfiles/public_suffix_2.rb } - - { os: ubuntu-18.04, ruby: 2.7, gemfile: gemfiles/public_suffix_3.rb } - # Ubuntu 20.04 - - { os: ubuntu-20.04, ruby: 2.7 } - - { os: ubuntu-20.04, ruby: '3.0' } - - { os: ubuntu-20.04, ruby: 3.1 } + - { os: ubuntu-20.04, ruby: 2.7, gemfile: gemfiles/public_suffix_2.rb } + - { os: ubuntu-20.04, ruby: 2.7, gemfile: gemfiles/public_suffix_3.rb } + # Ubuntu + - { os: ubuntu-18.04, ruby: 2.7 } + - { os: ubuntu-22.04, ruby: 3.1 } # macOS - { os: macos-11, ruby: 3.1 } - { os: macos-12, ruby: 3.1 } From cde690be31ca1989e66adaa15e9cbb296d87fe49 Mon Sep 17 00:00:00 2001 From: Patrik Ragnarsson Date: Mon, 25 Jul 2022 18:42:30 +0200 Subject: [PATCH 21/28] Add `public_suffix` 4 job --- .github/workflows/test.yml | 1 + gemfiles/public_suffix_4.rb | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100644 gemfiles/public_suffix_4.rb diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index af55bd56..6f67e17a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -102,6 +102,7 @@ jobs: include: - { os: ubuntu-20.04, ruby: 2.7, gemfile: gemfiles/public_suffix_2.rb } - { os: ubuntu-20.04, ruby: 2.7, gemfile: gemfiles/public_suffix_3.rb } + - { os: ubuntu-20.04, ruby: 2.7, gemfile: gemfiles/public_suffix_4.rb } # Ubuntu - { os: ubuntu-18.04, ruby: 2.7 } - { os: ubuntu-22.04, ruby: 3.1 } diff --git a/gemfiles/public_suffix_4.rb b/gemfiles/public_suffix_4.rb new file mode 100644 index 00000000..84936d2c --- /dev/null +++ b/gemfiles/public_suffix_4.rb @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +# Assumes this gemfile is used from the project root +eval_gemfile "../Gemfile" + +gem "public_suffix", "~> 4.0" From cbd5258660f426851fb9877b1809bbc1987b7331 Mon Sep 17 00:00:00 2001 From: Patrik Ragnarsson Date: Mon, 25 Jul 2022 18:43:29 +0200 Subject: [PATCH 22/28] Make it more clear which jobs are allowed to fail Switch them to Ubuntu 20.04. --- .github/workflows/test.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6f67e17a..c835efcf 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -91,10 +91,8 @@ jobs: - jruby-9.1 - jruby-9.2 - jruby-9.3 - - jruby-head - truffleruby-21.3 - truffleruby-22.1 - - truffleruby-head os: - ubuntu-20.04 gemfile: @@ -114,8 +112,8 @@ jobs: - { os: windows-2022, ruby: 3.1 } - { os: windows-2022, ruby: jruby-9.3 } # allowed to fail - - { os: ubuntu-18.04, ruby: jruby-head, allow-failure: true } - - { os: ubuntu-18.04, ruby: truffleruby-head, allow-failure: true } + - { os: ubuntu-20.04, ruby: jruby-head, gemfile: Gemfile, allow-failure: true } + - { os: ubuntu-20.04, ruby: truffleruby-head, gemfile: Gemfile, allow-failure: true } env: BUNDLE_GEMFILE: ${{ matrix.gemfile }} BUNDLE_WITHOUT: development:coverage From eed9ed082372a84bc3f49f6f9d80a2701c76e363 Mon Sep 17 00:00:00 2001 From: Patrik Ragnarsson Date: Mon, 25 Jul 2022 18:45:03 +0200 Subject: [PATCH 23/28] Use Ubuntu 20.04 for profile and coverage jobs --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c835efcf..c92def75 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,7 +14,7 @@ jobs: matrix: ruby: [2.7] idna_mode: [native, pure] - os: [ubuntu-18.04] + os: [ubuntu-20.04] env: IDNA_MODE: ${{ matrix.idna_mode }} steps: @@ -46,7 +46,7 @@ jobs: fail-fast: false matrix: ruby: [2.7] - os: [ubuntu-18.04] + os: [ubuntu-20.04] env: BUNDLE_WITHOUT: development COVERALLS_SERVICE_NAME: github From 8933388cb5fadd738d56dee777c0d3ed1cdcb7d7 Mon Sep 17 00:00:00 2001 From: Patrik Ragnarsson Date: Mon, 25 Jul 2022 18:53:39 +0200 Subject: [PATCH 24/28] Bump actions/checkout --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c92def75..d372d8ad 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,7 +18,7 @@ jobs: env: IDNA_MODE: ${{ matrix.idna_mode }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Install libidn run: sudo apt-get install libidn11-dev @@ -54,7 +54,7 @@ jobs: COVERALLS_DEBUG: true CI_BUILD_NUMBER: ${{ github.run_id }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Install libidn run: sudo apt-get install libidn11-dev @@ -122,7 +122,7 @@ jobs: # https://github.com/jruby/jruby/issues/7182#issuecomment-1112953015 JAVA_OPTS: -Djdk.io.File.enableADS=true steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Install libidn (Ubuntu) if: startsWith(matrix.os, 'ubuntu') From d77ba6b8ef8ce7d1f3f2e701fcc4ee6548e635ea Mon Sep 17 00:00:00 2001 From: Peter Goldstein Date: Tue, 26 Jul 2022 14:55:23 -0400 Subject: [PATCH 25/28] Add GitHub Actions to Dependabot --- .github/dependabot.yml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..5ace4600 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" From e3b04ebab73ad7e5c35bdf02d4ca84021be725e5 Mon Sep 17 00:00:00 2001 From: Adrien Rey-Jarthon Date: Sat, 2 Jul 2022 12:01:52 +0200 Subject: [PATCH 26/28] fix "invalid byte sequence in UTF-8" exception when unencoding URLs containing non UTF-8 characters --- lib/addressable/uri.rb | 12 +++--------- spec/addressable/uri_spec.rb | 5 +++++ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/addressable/uri.rb b/lib/addressable/uri.rb index 6e55cda9..3ded0e87 100644 --- a/lib/addressable/uri.rb +++ b/lib/addressable/uri.rb @@ -468,19 +468,13 @@ def self.unencode(uri, return_type=String, leave_encoded='') "Expected Class (String or Addressable::URI), " + "got #{return_type.inspect}" end - uri = uri.dup - # Seriously, only use UTF-8. I'm really not kidding! - uri.force_encoding("utf-8") - unless leave_encoded.empty? - leave_encoded = leave_encoded.dup.force_encoding("utf-8") - end - - result = uri.gsub(/%[0-9a-f]{2}/iu) do |sequence| + result = uri.gsub(/%[0-9a-f]{2}/i) do |sequence| c = sequence[1..3].to_i(16).chr - c.force_encoding("utf-8") + c.force_encoding(sequence.encoding) leave_encoded.include?(c) ? sequence : c end + result.force_encoding("utf-8") if return_type == String return result diff --git a/spec/addressable/uri_spec.rb b/spec/addressable/uri_spec.rb index 76edaad0..b8ca5213 100644 --- a/spec/addressable/uri_spec.rb +++ b/spec/addressable/uri_spec.rb @@ -5992,6 +5992,11 @@ def to_str expect(Addressable::URI.unencode_component("ski=%BA%DAɫ")).to eq("ski=\xBA\xDAɫ") end + it "should not fail with UTF-8 incompatible string" do + url = "/M%E9/\xE9?p=\xFC".b + expect(Addressable::URI.unencode_component(url)).to eq("/M\xE9/\xE9?p=\xFC") + end + it "should result in correct percent encoded sequence as a URI" do expect(Addressable::URI.unencode( "/path?g%C3%BCnther", ::Addressable::URI From f968b358fd30bcca1da3eb7a6cae80a6349f6b59 Mon Sep 17 00:00:00 2001 From: Bob Aman Date: Fri, 29 Jul 2022 20:20:08 -0700 Subject: [PATCH 27/28] Enable CodeQL analysis --- .github/workflows/codeql-analysis.yml | 53 +++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .github/workflows/codeql-analysis.yml diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 00000000..392e871b --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,53 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: [ "main" ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ "main" ] + schedule: + - cron: '41 19 * * 2' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'ruby' ] + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 From 31c23e23666633b267a82f0900f1776df35e6543 Mon Sep 17 00:00:00 2001 From: Bob Aman Date: Fri, 29 Jul 2022 20:21:33 -0700 Subject: [PATCH 28/28] Remove boilerplate --- .github/workflows/codeql-analysis.yml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 392e871b..7b2e23ed 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -1,14 +1,3 @@ -# For most projects, this workflow file will not need changing; you simply need -# to commit it to your repository. -# -# You may wish to alter this file to override the set of languages analyzed, -# or to provide custom queries or build logic. -# -# ******** NOTE ******** -# We have attempted to detect the languages in your repository. Please check -# the `language` matrix defined below to confirm you have the correct set of -# supported CodeQL languages. -# name: "CodeQL" on: