From 69116ff436b06e08f858487f2285b7c3e1ddb3c4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Dec 2023 00:48:29 +0000 Subject: [PATCH 01/92] Bump actions/deploy-pages from 2 to 3 Bumps [actions/deploy-pages](https://github.com/actions/deploy-pages) from 2 to 3. - [Release notes](https://github.com/actions/deploy-pages/releases) - [Commits](https://github.com/actions/deploy-pages/compare/v2...v3) --- updated-dependencies: - dependency-name: actions/deploy-pages dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/gh-pages.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index a4f155a..6f51f54 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -43,4 +43,4 @@ jobs: steps: - name: Deploy to GitHub Pages id: deployment - uses: actions/deploy-pages@v2 + uses: actions/deploy-pages@v3 From fba4daa5ca6e9420c9874c1c7221791990776e50 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Dec 2023 00:48:33 +0000 Subject: [PATCH 02/92] Bump actions/configure-pages from 3 to 4 Bumps [actions/configure-pages](https://github.com/actions/configure-pages) from 3 to 4. - [Release notes](https://github.com/actions/configure-pages/releases) - [Commits](https://github.com/actions/configure-pages/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/configure-pages dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/gh-pages.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index a4f155a..74d8b5b 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -27,7 +27,7 @@ jobs: bundler-cache: true - name: Setup Pages id: pages - uses: actions/configure-pages@v3 + uses: actions/configure-pages@v4 - name: Build with RDoc # Outputs to the './_site' directory by default run: bundle exec rake rdoc From f3e5b0c97d98989f75929bb33e275ce5feb33fb7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Dec 2023 00:19:22 +0000 Subject: [PATCH 03/92] Bump actions/upload-pages-artifact from 2 to 3 Bumps [actions/upload-pages-artifact](https://github.com/actions/upload-pages-artifact) from 2 to 3. - [Release notes](https://github.com/actions/upload-pages-artifact/releases) - [Commits](https://github.com/actions/upload-pages-artifact/compare/v2...v3) --- updated-dependencies: - dependency-name: actions/upload-pages-artifact dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/gh-pages.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index 8683e26..19aa794 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -32,7 +32,7 @@ jobs: # Outputs to the './_site' directory by default run: bundle exec rake rdoc - name: Upload artifact - uses: actions/upload-pages-artifact@v2 + uses: actions/upload-pages-artifact@v3 deploy: environment: From 15f76263462b1bd4168a6a30df96965457a41357 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Dec 2023 00:19:27 +0000 Subject: [PATCH 04/92] Bump actions/deploy-pages from 3 to 4 Bumps [actions/deploy-pages](https://github.com/actions/deploy-pages) from 3 to 4. - [Release notes](https://github.com/actions/deploy-pages/releases) - [Commits](https://github.com/actions/deploy-pages/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/deploy-pages dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/gh-pages.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index 8683e26..203af73 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -43,4 +43,4 @@ jobs: steps: - name: Deploy to GitHub Pages id: deployment - uses: actions/deploy-pages@v3 + uses: actions/deploy-pages@v4 From ac32aa005b283e036003989fb2e625cdde462a36 Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Tue, 24 Oct 2023 13:26:03 -0700 Subject: [PATCH 05/92] Make URI#to_s prepend relative path with / if there is a host or port Otherwise, the path could be considered part of the host or port. This is better than modifying the path to make it absolute when a host or port is set. We could also raise for invalid paths when a host or port is set using check_path, but that results in weird errors, and won't catch issues (such as ftp allowing a relative path). Fixes [Bug #19916] --- lib/uri/generic.rb | 3 +++ test/uri/test_generic.rb | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/lib/uri/generic.rb b/lib/uri/generic.rb index f3540a2..9ea2335 100644 --- a/lib/uri/generic.rb +++ b/lib/uri/generic.rb @@ -1364,6 +1364,9 @@ def to_s str << ':' str << @port.to_s end + if (@host || @port) && !@path.empty? && !@path.start_with?('/') + str << '/' + end str << @path if @query str << '?' diff --git a/test/uri/test_generic.rb b/test/uri/test_generic.rb index e661937..8209363 100644 --- a/test/uri/test_generic.rb +++ b/test/uri/test_generic.rb @@ -26,6 +26,17 @@ def test_to_s assert_equal "postgres:///foo", URI("postgres:///foo").to_s assert_equal "http:///foo", URI("http:///foo").to_s assert_equal "http:/foo", URI("http:/foo").to_s + + uri = URI('rel_path') + assert_equal "rel_path", uri.to_s + uri.scheme = 'http' + assert_equal "http:rel_path", uri.to_s + uri.host = 'h' + assert_equal "http://h/rel_path", uri.to_s + uri.port = 8080 + assert_equal "http://h:8080/rel_path", uri.to_s + uri.host = nil + assert_equal "http::8080/rel_path", uri.to_s end def test_parse From feb8e0dd731c573e1b4384138b2140040f2eefdc Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Fri, 19 Jan 2024 20:09:32 +0900 Subject: [PATCH 06/92] Removed commented-out code --- lib/uri/generic.rb | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/lib/uri/generic.rb b/lib/uri/generic.rb index 9ea2335..baa6a4c 100644 --- a/lib/uri/generic.rb +++ b/lib/uri/generic.rb @@ -1402,19 +1402,6 @@ def eql?(oth) self.component_ary.eql?(oth.component_ary) end -=begin - ---- URI::Generic#===(oth) - -=end -# def ===(oth) -# raise NotImplementedError -# end - -=begin -=end - - # Returns an Array of the components defined from the COMPONENT Array. def component_ary component.collect do |x| From ad2591f0d190eecfbc0f85e5d98bdd8cb17dc5b9 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Tue, 20 Feb 2024 16:57:45 +0900 Subject: [PATCH 07/92] Use https instead of http --- lib/uri.rb | 18 +++++++++--------- lib/uri/ftp.rb | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/uri.rb b/lib/uri.rb index 59a7c4a..cd8083b 100644 --- a/lib/uri.rb +++ b/lib/uri.rb @@ -1,6 +1,6 @@ # frozen_string_literal: false # URI is a module providing classes to handle Uniform Resource Identifiers -# (RFC2396[http://tools.ietf.org/html/rfc2396]). +# (RFC2396[https://datatracker.ietf.org/doc/html/rfc2396]). # # == Features # @@ -47,14 +47,14 @@ # A good place to view an RFC spec is http://www.ietf.org/rfc.html. # # Here is a list of all related RFC's: -# - RFC822[http://tools.ietf.org/html/rfc822] -# - RFC1738[http://tools.ietf.org/html/rfc1738] -# - RFC2255[http://tools.ietf.org/html/rfc2255] -# - RFC2368[http://tools.ietf.org/html/rfc2368] -# - RFC2373[http://tools.ietf.org/html/rfc2373] -# - RFC2396[http://tools.ietf.org/html/rfc2396] -# - RFC2732[http://tools.ietf.org/html/rfc2732] -# - RFC3986[http://tools.ietf.org/html/rfc3986] +# - RFC822[https://datatracker.ietf.org/doc/html/rfc822] +# - RFC1738[https://datatracker.ietf.org/doc/html/rfc1738] +# - RFC2255[https://datatracker.ietf.org/doc/html/rfc2255] +# - RFC2368[https://datatracker.ietf.org/doc/html/rfc2368] +# - RFC2373[https://datatracker.ietf.org/doc/html/rfc2373] +# - RFC2396[https://datatracker.ietf.org/doc/html/rfc2396] +# - RFC2732[https://datatracker.ietf.org/doc/html/rfc2732] +# - RFC3986[https://datatracker.ietf.org/doc/html/rfc3986] # # == Class tree # diff --git a/lib/uri/ftp.rb b/lib/uri/ftp.rb index abad613..1c75e24 100644 --- a/lib/uri/ftp.rb +++ b/lib/uri/ftp.rb @@ -17,7 +17,7 @@ module URI # This class will be redesigned because of difference of implementations; # the structure of its path. draft-hoffman-ftp-uri-04 is a draft but it # is a good summary about the de facto spec. - # http://tools.ietf.org/html/draft-hoffman-ftp-uri-04 + # https://datatracker.ietf.org/doc/html/draft-hoffman-ftp-uri-04 # class FTP < Generic # A Default port of 21 for URI::FTP. From c7f818378b7fb7e7cea8de38b93c3532f3cee264 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Thu, 28 Mar 2024 09:45:01 +0900 Subject: [PATCH 08/92] Use www.rfc-editor.org for RFC text. We use the following site for that now: * https://tools.ietf.org/ or http * https://datatracker.ietf.org or http Today, IETF said the official site of RFC is www.rfc-editor.org. FYI: https://authors.ietf.org/en/references-in-rfcxml I replaced them to www.rfc-editor.org. --- lib/uri.rb | 18 +++++++++--------- lib/uri/generic.rb | 2 +- lib/uri/http.rb | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/uri.rb b/lib/uri.rb index cd8083b..dfdb052 100644 --- a/lib/uri.rb +++ b/lib/uri.rb @@ -1,6 +1,6 @@ # frozen_string_literal: false # URI is a module providing classes to handle Uniform Resource Identifiers -# (RFC2396[https://datatracker.ietf.org/doc/html/rfc2396]). +# (RFC2396[https://www.rfc-editor.org/rfc/rfc2396]). # # == Features # @@ -47,14 +47,14 @@ # A good place to view an RFC spec is http://www.ietf.org/rfc.html. # # Here is a list of all related RFC's: -# - RFC822[https://datatracker.ietf.org/doc/html/rfc822] -# - RFC1738[https://datatracker.ietf.org/doc/html/rfc1738] -# - RFC2255[https://datatracker.ietf.org/doc/html/rfc2255] -# - RFC2368[https://datatracker.ietf.org/doc/html/rfc2368] -# - RFC2373[https://datatracker.ietf.org/doc/html/rfc2373] -# - RFC2396[https://datatracker.ietf.org/doc/html/rfc2396] -# - RFC2732[https://datatracker.ietf.org/doc/html/rfc2732] -# - RFC3986[https://datatracker.ietf.org/doc/html/rfc3986] +# - RFC822[https://www.rfc-editor.org/rfc/rfc822] +# - RFC1738[https://www.rfc-editor.org/rfc/rfc1738] +# - RFC2255[https://www.rfc-editor.org/rfc/rfc2255] +# - RFC2368[https://www.rfc-editor.org/rfc/rfc2368] +# - RFC2373[https://www.rfc-editor.org/rfc/rfc2373] +# - RFC2396[https://www.rfc-editor.org/rfc/rfc2396] +# - RFC2732[https://www.rfc-editor.org/rfc/rfc2732] +# - RFC3986[https://www.rfc-editor.org/rfc/rfc3986] # # == Class tree # diff --git a/lib/uri/generic.rb b/lib/uri/generic.rb index baa6a4c..bdd3666 100644 --- a/lib/uri/generic.rb +++ b/lib/uri/generic.rb @@ -945,7 +945,7 @@ def fragment=(v) # == Description # # URI has components listed in order of decreasing significance from left to right, - # see RFC3986 https://tools.ietf.org/html/rfc3986 1.2.3. + # see RFC3986 https://www.rfc-editor.org/rfc/rfc3986 1.2.3. # # == Usage # diff --git a/lib/uri/http.rb b/lib/uri/http.rb index 306daf1..900b132 100644 --- a/lib/uri/http.rb +++ b/lib/uri/http.rb @@ -85,7 +85,7 @@ def request_uri # == Description # # Returns the authority for an HTTP uri, as defined in - # https://datatracker.ietf.org/doc/html/rfc3986/#section-3.2. + # https://www.rfc-editor.org/rfc/rfc3986#section-3.2. # # # Example: @@ -106,7 +106,7 @@ def authority # == Description # # Returns the origin for an HTTP uri, as defined in - # https://datatracker.ietf.org/doc/html/rfc6454. + # https://www.rfc-editor.org/rfc/rfc6454. # # # Example: From 554438f4e0f88013adc675d2e874dc661d4bbd89 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Apr 2024 01:17:32 +0000 Subject: [PATCH 09/92] Bump actions/configure-pages from 4 to 5 Bumps [actions/configure-pages](https://github.com/actions/configure-pages) from 4 to 5. - [Release notes](https://github.com/actions/configure-pages/releases) - [Commits](https://github.com/actions/configure-pages/compare/v4...v5) --- updated-dependencies: - dependency-name: actions/configure-pages dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/gh-pages.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index 7aed1b2..c30ff22 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -27,7 +27,7 @@ jobs: bundler-cache: true - name: Setup Pages id: pages - uses: actions/configure-pages@v4 + uses: actions/configure-pages@v5 - name: Build with RDoc # Outputs to the './_site' directory by default run: bundle exec rake rdoc From bf9012fa58d25208229e72ca637bdcc699fba95b Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Tue, 11 Jun 2024 07:06:32 +0200 Subject: [PATCH 10/92] Exclude Ruby 2.5 from Apple Silicon --- .github/workflows/test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6cf5ef7..ee9b2a5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,6 +15,9 @@ jobs: matrix: ruby: ${{ fromJson(needs.ruby-versions.outputs.versions) }} os: [ ubuntu-latest, macos-latest ] + exclude: + - ruby: 2.5 + os: macos-latest runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 From e84670a9e2e0c40eba8d722c1b26929cd5bd6ce8 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Tue, 11 Jun 2024 07:07:31 +0200 Subject: [PATCH 11/92] Update license files same as ruby/ruby repository --- LICENSE.txt => BSDL | 6 ++--- COPYING | 56 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 3 deletions(-) rename LICENSE.txt => BSDL (83%) create mode 100644 COPYING diff --git a/LICENSE.txt b/BSDL similarity index 83% rename from LICENSE.txt rename to BSDL index a009cae..66d9359 100644 --- a/LICENSE.txt +++ b/BSDL @@ -4,10 +4,10 @@ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. + notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..48e5a96 --- /dev/null +++ b/COPYING @@ -0,0 +1,56 @@ +Ruby is copyrighted free software by Yukihiro Matsumoto . +You can redistribute it and/or modify it under either the terms of the +2-clause BSDL (see the file BSDL), or the conditions below: + +1. You may make and give away verbatim copies of the source form of the + software without restriction, provided that you duplicate all of the + original copyright notices and associated disclaimers. + +2. You may modify your copy of the software in any way, provided that + you do at least ONE of the following: + + a. place your modifications in the Public Domain or otherwise + make them Freely Available, such as by posting said + modifications to Usenet or an equivalent medium, or by allowing + the author to include your modifications in the software. + + b. use the modified software only within your corporation or + organization. + + c. give non-standard binaries non-standard names, with + instructions on where to get the original software distribution. + + d. make other distribution arrangements with the author. + +3. You may distribute the software in object code or binary form, + provided that you do at least ONE of the following: + + a. distribute the binaries and library files of the software, + together with instructions (in the manual page or equivalent) + on where to get the original distribution. + + b. accompany the distribution with the machine-readable source of + the software. + + c. give non-standard binaries non-standard names, with + instructions on where to get the original software distribution. + + d. make other distribution arrangements with the author. + +4. You may modify and include the part of the software into any other + software (possibly commercial). But some files in the distribution + are not written by the author, so that they are not under these terms. + + For the list of those files and their copying conditions, see the + file LEGAL. + +5. The scripts and library files supplied as input to or produced as + output from the software do not automatically fall under the + copyright of the software, but belong to whomever generated them, + and may be sold commercially, and may be aggregated with this + software. + +6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + PURPOSE. From 9f2c7ed5f2e2c4060c05e3db8fa1dc73dd24ba0f Mon Sep 17 00:00:00 2001 From: Josh Soref Date: Mon, 28 Mar 2022 21:17:51 -0400 Subject: [PATCH 12/92] Add space after `bad URI` --- lib/uri/rfc2396_parser.rb | 6 +++--- lib/uri/rfc3986_parser.rb | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/uri/rfc2396_parser.rb b/lib/uri/rfc2396_parser.rb index 00c66cf..a56ca34 100644 --- a/lib/uri/rfc2396_parser.rb +++ b/lib/uri/rfc2396_parser.rb @@ -140,11 +140,11 @@ def split(uri) if !scheme raise InvalidURIError, - "bad URI(absolute but no scheme): #{uri}" + "bad URI (absolute but no scheme): #{uri}" end if !opaque && (!path && (!host && !registry)) raise InvalidURIError, - "bad URI(absolute but no path): #{uri}" + "bad URI (absolute but no path): #{uri}" end when @regexp[:REL_URI] @@ -173,7 +173,7 @@ def split(uri) # server = [ [ userinfo "@" ] hostport ] else - raise InvalidURIError, "bad URI(is not URI?): #{uri}" + raise InvalidURIError, "bad URI (is not URI?): #{uri}" end path = '' if !path && !opaque # (see RFC2396 Section 5.2) diff --git a/lib/uri/rfc3986_parser.rb b/lib/uri/rfc3986_parser.rb index 092a1ac..0f63c48 100644 --- a/lib/uri/rfc3986_parser.rb +++ b/lib/uri/rfc3986_parser.rb @@ -78,7 +78,7 @@ def split(uri) #:nodoc: begin uri = uri.to_str rescue NoMethodError - raise InvalidURIError, "bad URI(is not URI?): #{uri.inspect}" + raise InvalidURIError, "bad URI (is not URI?): #{uri.inspect}" end uri.ascii_only? or raise InvalidURIError, "URI must be ascii only #{uri.dump}" @@ -127,7 +127,7 @@ def split(uri) #:nodoc: m["fragment"] ] else - raise InvalidURIError, "bad URI(is not URI?): #{uri.inspect}" + raise InvalidURIError, "bad URI (is not URI?): #{uri.inspect}" end end From d7dc19ad3fc5efe094abb4bffbe6b80a1d7aacae Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Wed, 17 Jul 2024 18:53:54 +0900 Subject: [PATCH 13/92] Added URI.parser= method for switch back to RFC2396_Parser --- lib/uri/common.rb | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/lib/uri/common.rb b/lib/uri/common.rb index faf75f0..1d381e7 100644 --- a/lib/uri/common.rb +++ b/lib/uri/common.rb @@ -13,24 +13,34 @@ require_relative "rfc3986_parser" module URI - include RFC2396_REGEXP + RFC2396_PARSER = RFC2396_Parser.new + Ractor.make_shareable(RFC2396_PARSER) if defined?(Ractor) - REGEXP = RFC2396_REGEXP - Parser = RFC2396_Parser RFC3986_PARSER = RFC3986_Parser.new Ractor.make_shareable(RFC3986_PARSER) if defined?(Ractor) - # URI::Parser.new - DEFAULT_PARSER = Parser.new - DEFAULT_PARSER.pattern.each_pair do |sym, str| - unless REGEXP::PATTERN.const_defined?(sym) - REGEXP::PATTERN.const_set(sym, str) + DEFAULT_PARSER = RFC3986_PARSER + Ractor.make_shareable(DEFAULT_PARSER) if defined?(Ractor) + + def self.parser=(parser = RFC3986_PARSER) + remove_const(:Parser) if defined?(Parser) + const_set("Parser", parser.class) + + if Parser == RFC2396_Parser + remove_const(:REGEXP) if defined?(REGEXP) + const_set("REGEXP", URI::RFC2396_REGEXP) + Parser.new.pattern.each_pair do |sym, str| + unless REGEXP::PATTERN.const_defined?(sym) + REGEXP::PATTERN.const_set(sym, str) + end + end + end + Parser.new.regexp.each_pair do |sym, str| + remove_const(sym) if const_defined?(sym) + const_set(sym, str) end end - DEFAULT_PARSER.regexp.each_pair do |sym, str| - const_set(sym, str) - end - Ractor.make_shareable(DEFAULT_PARSER) if defined?(Ractor) + self.parser = RFC3986_PARSER module Util # :nodoc: def make_components_hash(klass, array_hash) From bbb8a40eae3d11521113a111e5f8ab8f6d6f40c3 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Thu, 18 Jul 2024 10:11:13 +0900 Subject: [PATCH 14/92] Added compatibility methods for RFC2396 parser --- lib/uri/rfc3986_parser.rb | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/uri/rfc3986_parser.rb b/lib/uri/rfc3986_parser.rb index 092a1ac..dbb352f 100644 --- a/lib/uri/rfc3986_parser.rb +++ b/lib/uri/rfc3986_parser.rb @@ -135,12 +135,31 @@ def parse(uri) # :nodoc: URI.for(*self.split(uri), self) end - def join(*uris) # :nodoc: uris[0] = convert_to_uri(uris[0]) uris.inject :merge end + # Compatibility for RFC2396 parser + def extract(str, schemes = nil) # :nodoc: + RFC2396_PARSER.extract(str, schemes) + end + + # Compatibility for RFC2396 parser + def make_regexp(schemes = nil) # :nodoc: + RFC2396_PARSER.make_regexp(schemes) + end + + # Compatibility for RFC2396 parser + def escape(str, unsafe = nil) # :nodoc: + unsafe ? RFC2396_PARSER.escape(str, unsafe) : RFC2396_PARSER.escape(str) + end + + # Compatibility for RFC2396 parser + def unescape(str, escaped = nil) # :nodoc: + escaped ? RFC2396_PARSER.unescape(str, escaped) : RFC2396_PARSER.unescape(str) + end + @@to_s = Kernel.instance_method(:to_s) if @@to_s.respond_to?(:bind_call) def inspect From 0ab9abbf088654f1a71de5302b6282006cfb3942 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Thu, 18 Jul 2024 10:11:29 +0900 Subject: [PATCH 15/92] Switch to inspect with default parser --- test/uri/test_parser.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/uri/test_parser.rb b/test/uri/test_parser.rb index 75c02fe..f400de2 100644 --- a/test/uri/test_parser.rb +++ b/test/uri/test_parser.rb @@ -8,8 +8,8 @@ def uri_to_ary(uri) end def test_inspect - assert_match(/URI::RFC2396_Parser/, URI::Parser.new.inspect) - assert_match(/URI::RFC3986_Parser/, URI::RFC3986_Parser.new.inspect) + assert_match(/URI::RFC2396_Parser/, URI::RFC2396_Parser.new.inspect) + assert_match(/URI::RFC3986_Parser/, URI::Parser.new.inspect) end def test_compare From 2e0f73f05e9ad226356a2dde89f53feb41d59cc9 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Thu, 18 Jul 2024 10:27:25 +0900 Subject: [PATCH 16/92] Rename and switch RFC2396_PARSER test --- test/uri/test_parser.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/uri/test_parser.rb b/test/uri/test_parser.rb index f400de2..9105d47 100644 --- a/test/uri/test_parser.rb +++ b/test/uri/test_parser.rb @@ -33,7 +33,9 @@ def test_compare assert(!u2.equal?(u3)) end - def test_parse + def test_parse_rfc2396_parser + URI.parser = URI::RFC2396_PARSER + escaped = URI::REGEXP::PATTERN::ESCAPED hex = URI::REGEXP::PATTERN::HEX p1 = URI::Parser.new(:ESCAPED => "(?:#{escaped}|%u[#{hex}]{4})") @@ -43,6 +45,8 @@ def test_parse u1.path = '/%uDCBA' assert_equal(['http', nil, 'a', URI::HTTP.default_port, '/%uDCBA', nil, nil], uri_to_ary(u1)) + ensure + URI.parser = URI::DEFAULT_PARSER end def test_parse_query_pct_encoded From 984145c407c074d93ab7ca50e12afc2be7333804 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Thu, 18 Jul 2024 11:58:26 +0900 Subject: [PATCH 17/92] URI.extract needs to pass block If given block to URI.extract, it returns nil. --- lib/uri/rfc3986_parser.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/uri/rfc3986_parser.rb b/lib/uri/rfc3986_parser.rb index dbb352f..529ecfa 100644 --- a/lib/uri/rfc3986_parser.rb +++ b/lib/uri/rfc3986_parser.rb @@ -141,8 +141,8 @@ def join(*uris) # :nodoc: end # Compatibility for RFC2396 parser - def extract(str, schemes = nil) # :nodoc: - RFC2396_PARSER.extract(str, schemes) + def extract(str, schemes = nil, &block) # :nodoc: + RFC2396_PARSER.extract(str, schemes, &block) end # Compatibility for RFC2396 parser From 6f616d97fc9ec9e74c21a396206c2eb9ba907552 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Thu, 18 Jul 2024 13:16:20 +0900 Subject: [PATCH 18/92] Added test for constant definition and remove URI::REGEXP when using RFC3986_PARSER --- lib/uri/common.rb | 3 ++- test/uri/test_common.rb | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/uri/common.rb b/lib/uri/common.rb index 1d381e7..034b91c 100644 --- a/lib/uri/common.rb +++ b/lib/uri/common.rb @@ -26,8 +26,8 @@ def self.parser=(parser = RFC3986_PARSER) remove_const(:Parser) if defined?(Parser) const_set("Parser", parser.class) + remove_const(:REGEXP) if defined?(REGEXP) if Parser == RFC2396_Parser - remove_const(:REGEXP) if defined?(REGEXP) const_set("REGEXP", URI::RFC2396_REGEXP) Parser.new.pattern.each_pair do |sym, str| unless REGEXP::PATTERN.const_defined?(sym) @@ -35,6 +35,7 @@ def self.parser=(parser = RFC3986_PARSER) end end end + Parser.new.regexp.each_pair do |sym, str| remove_const(sym) if const_defined?(sym) const_set(sym, str) diff --git a/test/uri/test_common.rb b/test/uri/test_common.rb index 1df19e6..8d0a206 100644 --- a/test/uri/test_common.rb +++ b/test/uri/test_common.rb @@ -10,6 +10,23 @@ def setup def teardown end + def test_parser_switch + assert_equal(URI::Parser, URI::RFC3986_Parser) + refute defined?(::URI::REGEXP) + + URI.parser = URI::RFC2396_PARSER + + assert_equal(URI::Parser, URI::RFC2396_Parser) + assert defined?(URI::REGEXP) + + URI.parser = URI::RFC3986_PARSER + + assert_equal(URI::Parser, URI::RFC3986_Parser) + refute defined?(URI::REGEXP) + ensure + URI.parser = URI::RFC3986_PARSER + end + def test_extract EnvUtil.suppress_warning do assert_equal(['http://example.com'], From 823697edb4eb1d6f43e6864d00e99797888265a6 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Thu, 18 Jul 2024 13:31:17 +0900 Subject: [PATCH 19/92] Also support URI::PATTERN with switch-back --- lib/uri/common.rb | 2 ++ test/uri/test_common.rb | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/uri/common.rb b/lib/uri/common.rb index 034b91c..b5b6177 100644 --- a/lib/uri/common.rb +++ b/lib/uri/common.rb @@ -27,8 +27,10 @@ def self.parser=(parser = RFC3986_PARSER) const_set("Parser", parser.class) remove_const(:REGEXP) if defined?(REGEXP) + remove_const(:PATTERN) if defined?(PATTERN) if Parser == RFC2396_Parser const_set("REGEXP", URI::RFC2396_REGEXP) + const_set("PATTERN", URI::RFC2396_REGEXP::PATTERN) Parser.new.pattern.each_pair do |sym, str| unless REGEXP::PATTERN.const_defined?(sym) REGEXP::PATTERN.const_set(sym, str) diff --git a/test/uri/test_common.rb b/test/uri/test_common.rb index 8d0a206..aa9c689 100644 --- a/test/uri/test_common.rb +++ b/test/uri/test_common.rb @@ -12,17 +12,21 @@ def teardown def test_parser_switch assert_equal(URI::Parser, URI::RFC3986_Parser) - refute defined?(::URI::REGEXP) + refute defined?(URI::REGEXP) + refute defined?(URI::PATTERN) URI.parser = URI::RFC2396_PARSER assert_equal(URI::Parser, URI::RFC2396_Parser) assert defined?(URI::REGEXP) + assert defined?(URI::PATTERN) + assert defined?(URI::PATTERN::ESCAPED) URI.parser = URI::RFC3986_PARSER assert_equal(URI::Parser, URI::RFC3986_Parser) refute defined?(URI::REGEXP) + refute defined?(URI::PATTERN) ensure URI.parser = URI::RFC3986_PARSER end From 7a64e0245fa7d98468d4a217b9e20ea7b9b87a1e Mon Sep 17 00:00:00 2001 From: Randy Stauner Date: Fri, 19 Jul 2024 08:55:31 -0700 Subject: [PATCH 20/92] Restrict constant checks to current namespace to avoid conflicts with globals --- lib/uri/common.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/uri/common.rb b/lib/uri/common.rb index b5b6177..6ef07c8 100644 --- a/lib/uri/common.rb +++ b/lib/uri/common.rb @@ -23,11 +23,11 @@ module URI Ractor.make_shareable(DEFAULT_PARSER) if defined?(Ractor) def self.parser=(parser = RFC3986_PARSER) - remove_const(:Parser) if defined?(Parser) + remove_const(:Parser) if defined?(::URI::Parser) const_set("Parser", parser.class) - remove_const(:REGEXP) if defined?(REGEXP) - remove_const(:PATTERN) if defined?(PATTERN) + remove_const(:REGEXP) if defined?(::URI::REGEXP) + remove_const(:PATTERN) if defined?(::URI::PATTERN) if Parser == RFC2396_Parser const_set("REGEXP", URI::RFC2396_REGEXP) const_set("PATTERN", URI::RFC2396_REGEXP::PATTERN) From cd1e539f27bd5c84ff6b000abda323306416217a Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Sun, 21 Jul 2024 10:05:03 -0700 Subject: [PATCH 21/92] Use Ruby 3.3 for gh_pages build Hopefully this will fix the following error: You have already activated uri 0.12.1, but your Gemfile requires uri 0.13.0. Since uri is a default gem, you can either remove your dependency on it or try updating to a newer version of bundler that supports uri as a default gem. --- .github/workflows/gh-pages.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index c30ff22..f0e6b5d 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -23,7 +23,7 @@ jobs: - name: Setup Ruby uses: ruby/setup-ruby@250fcd6a742febb1123a77a841497ccaa8b9e939 # v1.152.0 with: - ruby-version: '3.2' + ruby-version: '3.3' bundler-cache: true - name: Setup Pages id: pages From 28af4e155a30b71780e680ce943e00b132b6491f Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Mon, 5 Aug 2024 16:35:53 +0900 Subject: [PATCH 22/92] Use DEFAULT_PARSER at split, parse, join --- lib/uri/common.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/uri/common.rb b/lib/uri/common.rb index 6ef07c8..4e8210d 100644 --- a/lib/uri/common.rb +++ b/lib/uri/common.rb @@ -181,7 +181,7 @@ class BadURIError < Error; end # ["fragment", "top"]] # def self.split(uri) - RFC3986_PARSER.split(uri) + DEFAULT_PARSER.split(uri) end # Returns a new \URI object constructed from the given string +uri+: @@ -195,7 +195,7 @@ def self.split(uri) # if it may contain invalid URI characters. # def self.parse(uri) - RFC3986_PARSER.parse(uri) + DEFAULT_PARSER.parse(uri) end # Merges the given URI strings +str+ @@ -222,7 +222,7 @@ def self.parse(uri) # # => # # def self.join(*str) - RFC3986_PARSER.join(*str) + DEFAULT_PARSER.join(*str) end # From c2fdec079a69d4f0ced0ddfa12bda9e84449caba Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Tue, 6 Aug 2024 17:09:47 +0800 Subject: [PATCH 23/92] Fallback missing constants with RFC3986_PARSER (#113) * Fallback missing constants with RFC3986_PARSER * raise missing constant * Update test/uri/test_common.rb Co-authored-by: Nobuyoshi Nakada * Update lib/uri/common.rb Co-authored-by: Nobuyoshi Nakada * Update lib/uri/common.rb Co-authored-by: Nobuyoshi Nakada --------- Co-authored-by: Nobuyoshi Nakada --- lib/uri/common.rb | 9 +++++++++ test/uri/test_common.rb | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/lib/uri/common.rb b/lib/uri/common.rb index 4e8210d..cf93fb1 100644 --- a/lib/uri/common.rb +++ b/lib/uri/common.rb @@ -45,6 +45,15 @@ def self.parser=(parser = RFC3986_PARSER) end self.parser = RFC3986_PARSER + def self.const_missing(const) + if value = RFC2396_PARSER.regexp[const] + warn "URI::#{const} is obsolete. Use RFC2396_PARSER.regexp[#{const.inspect}] explicitly.", uplevel: 1 if $VERBOSE + value + else + super + end + end + module Util # :nodoc: def make_components_hash(klass, array_hash) tmp = {} diff --git a/test/uri/test_common.rb b/test/uri/test_common.rb index aa9c689..bccdeaf 100644 --- a/test/uri/test_common.rb +++ b/test/uri/test_common.rb @@ -10,6 +10,15 @@ def setup def teardown end + def test_fallback_constants + orig_verbose = $VERBOSE + $VERBOSE = nil + assert URI::ABS_URI + assert_raise(NameError) { URI::FOO } + ensure + $VERBOSE = orig_verbose + end + def test_parser_switch assert_equal(URI::Parser, URI::RFC3986_Parser) refute defined?(URI::REGEXP) From 9997c1aceedfc205aa4f956b17d09b88feaf2fe2 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Thu, 8 Aug 2024 10:44:52 +0900 Subject: [PATCH 24/92] Warn compatibility methods in RFC3986_PARSER --- lib/uri/rfc3986_parser.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/uri/rfc3986_parser.rb b/lib/uri/rfc3986_parser.rb index cac75a3..a8a8c74 100644 --- a/lib/uri/rfc3986_parser.rb +++ b/lib/uri/rfc3986_parser.rb @@ -147,16 +147,19 @@ def extract(str, schemes = nil, &block) # :nodoc: # Compatibility for RFC2396 parser def make_regexp(schemes = nil) # :nodoc: + warn "URI::RFC3986_PARSER.make_regexp is obsoleted. Use URI::RFC2396_PARSER.make_regexp explicitly.", uplevel: 1 if $VERBOSE RFC2396_PARSER.make_regexp(schemes) end # Compatibility for RFC2396 parser def escape(str, unsafe = nil) # :nodoc: + warn "URI::RFC3986_PARSER.escape is obsoleted. Use URI::RFC2396_PARSER.escape explicitly.", uplevel: 1 if $VERBOSE unsafe ? RFC2396_PARSER.escape(str, unsafe) : RFC2396_PARSER.escape(str) end # Compatibility for RFC2396 parser def unescape(str, escaped = nil) # :nodoc: + warn "URI::RFC3986_PARSER.unescape is obsoleted. Use URI::RFC2396_PARSER.unescape explicitly.", uplevel: 1 if $VERBOSE escaped ? RFC2396_PARSER.unescape(str, escaped) : RFC2396_PARSER.unescape(str) end From 898b889811e5978b967eb5c73fe3b273b736552c Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Thu, 8 Aug 2024 11:06:03 +0900 Subject: [PATCH 25/92] Use URI::RFC2396_PARSER explicitly in URI --- lib/uri/generic.rb | 4 ++-- test/uri/test_parser.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/uri/generic.rb b/lib/uri/generic.rb index bdd3666..7b48c9b 100644 --- a/lib/uri/generic.rb +++ b/lib/uri/generic.rb @@ -82,7 +82,7 @@ def self.build2(args) if args.kind_of?(Array) return self.build(args.collect{|x| if x.is_a?(String) - DEFAULT_PARSER.escape(x) + URI::RFC2396_PARSER.escape(x) else x end @@ -91,7 +91,7 @@ def self.build2(args) tmp = {} args.each do |key, value| tmp[key] = if value - DEFAULT_PARSER.escape(value) + URI::RFC2396_PARSER.escape(value) else value end diff --git a/test/uri/test_parser.rb b/test/uri/test_parser.rb index 9105d47..f455a5c 100644 --- a/test/uri/test_parser.rb +++ b/test/uri/test_parser.rb @@ -69,8 +69,8 @@ def test_raise_bad_uri_for_integer end end - def test_unescape - p1 = URI::Parser.new + def test_rfc2822_unescape + p1 = URI::RFC2396_Parser.new assert_equal("\xe3\x83\x90", p1.unescape("\xe3\x83\x90")) assert_equal("\xe3\x83\x90", p1.unescape('%e3%83%90')) assert_equal("\u3042", p1.unescape('%e3%81%82'.force_encoding(Encoding::US_ASCII))) From c0cfa04a6601fbabd465a6c3a16a8af997706462 Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Mon, 19 Aug 2024 16:42:40 -0700 Subject: [PATCH 26/92] Do not allow empty host names, as they are not allowed by RFC 3986 Pointed out by John Hawthorn. Fixes [Bug #20686] --- lib/uri/http.rb | 12 ++++++++++++ test/uri/test_generic.rb | 6 ++++-- test/uri/test_http.rb | 4 ++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/lib/uri/http.rb b/lib/uri/http.rb index 900b132..3c41cd4 100644 --- a/lib/uri/http.rb +++ b/lib/uri/http.rb @@ -61,6 +61,18 @@ def self.build(args) super(tmp) end + # Do not allow empty host names, as they are not allowed by RFC 3986. + def check_host(v) + ret = super + + if ret && v.empty? + raise InvalidComponentError, + "bad component(expected host component): #{v}" + end + + ret + end + # # == Description # diff --git a/test/uri/test_generic.rb b/test/uri/test_generic.rb index 8209363..ccea6cd 100644 --- a/test/uri/test_generic.rb +++ b/test/uri/test_generic.rb @@ -828,8 +828,10 @@ def test_ipv6 assert_equal("http://[::1]/bar", u.to_s) u.hostname = "::1" assert_equal("http://[::1]/bar", u.to_s) - u.hostname = "" - assert_equal("http:///bar", u.to_s) + + u = URI("file://foo/bar") + u.hostname = '' + assert_equal("file:///bar", u.to_s) end def test_build diff --git a/test/uri/test_http.rb b/test/uri/test_http.rb index e937b1a..96625a3 100644 --- a/test/uri/test_http.rb +++ b/test/uri/test_http.rb @@ -19,6 +19,10 @@ def test_build assert_kind_of(URI::HTTP, u) end + def test_build_empty_host + assert_raise(URI::InvalidComponentError) { URI::HTTP.build(host: '') } + end + def test_parse u = URI.parse('http://a') assert_kind_of(URI::HTTP, u) From 0f6b9455572cb5f491f3dc352a98e5ff73276d4f Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Tue, 27 Aug 2024 11:36:34 +0900 Subject: [PATCH 27/92] Also warn URI::RFC3986_PARSER.extract --- lib/uri/rfc3986_parser.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/uri/rfc3986_parser.rb b/lib/uri/rfc3986_parser.rb index a8a8c74..4000f13 100644 --- a/lib/uri/rfc3986_parser.rb +++ b/lib/uri/rfc3986_parser.rb @@ -142,6 +142,7 @@ def join(*uris) # :nodoc: # Compatibility for RFC2396 parser def extract(str, schemes = nil, &block) # :nodoc: + warn "URI::RFC3986_PARSER.extract is obsoleted. Use URI::RFC2396_PARSER.extract explicitly.", uplevel: 1 if $VERBOSE RFC2396_PARSER.extract(str, schemes, &block) end From 31ec9cea66e2856775f8281bfeabc7d433d0fab1 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Tue, 27 Aug 2024 14:23:38 +0900 Subject: [PATCH 28/92] Bump up 0.13.1 --- lib/uri/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/uri/version.rb b/lib/uri/version.rb index 2dafa57..bfe3f47 100644 --- a/lib/uri/version.rb +++ b/lib/uri/version.rb @@ -1,6 +1,6 @@ module URI # :stopdoc: - VERSION_CODE = '001300'.freeze + VERSION_CODE = '001301'.freeze VERSION = VERSION_CODE.scan(/../).collect{|n| n.to_i}.join('.').freeze # :startdoc: end From 77241d65084caebb4d2a13f4d7b52c94a8ec6b81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Tue, 17 Sep 2024 19:06:40 +0200 Subject: [PATCH 29/92] Fix spelling of "cannot" --- lib/uri/file.rb | 6 +++--- lib/uri/generic.rb | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/uri/file.rb b/lib/uri/file.rb index 4ff0bc0..940d361 100644 --- a/lib/uri/file.rb +++ b/lib/uri/file.rb @@ -70,17 +70,17 @@ def set_port(v) # raise InvalidURIError def check_userinfo(user) - raise URI::InvalidURIError, "can not set userinfo for file URI" + raise URI::InvalidURIError, "cannot set userinfo for file URI" end # raise InvalidURIError def check_user(user) - raise URI::InvalidURIError, "can not set user for file URI" + raise URI::InvalidURIError, "cannot set user for file URI" end # raise InvalidURIError def check_password(user) - raise URI::InvalidURIError, "can not set password for file URI" + raise URI::InvalidURIError, "cannot set password for file URI" end # do nothing diff --git a/lib/uri/generic.rb b/lib/uri/generic.rb index 7b48c9b..d4bfa3b 100644 --- a/lib/uri/generic.rb +++ b/lib/uri/generic.rb @@ -393,7 +393,7 @@ def check_userinfo(user, password = nil) def check_user(v) if @opaque raise InvalidURIError, - "can not set user with opaque" + "cannot set user with opaque" end return v unless v @@ -417,7 +417,7 @@ def check_user(v) def check_password(v, user = @user) if @opaque raise InvalidURIError, - "can not set password with opaque" + "cannot set password with opaque" end return v unless v @@ -596,7 +596,7 @@ def check_host(v) if @opaque raise InvalidURIError, - "can not set host with registry or opaque" + "cannot set host with registry or opaque" elsif parser.regexp[:HOST] !~ v raise InvalidComponentError, "bad component(expected host component): #{v}" @@ -685,7 +685,7 @@ def check_port(v) if @opaque raise InvalidURIError, - "can not set port with registry or opaque" + "cannot set port with registry or opaque" elsif !v.kind_of?(Integer) && parser.regexp[:PORT] !~ v raise InvalidComponentError, "bad component(expected port component): #{v.inspect}" @@ -733,17 +733,17 @@ def port=(v) end def check_registry(v) # :nodoc: - raise InvalidURIError, "can not set registry" + raise InvalidURIError, "cannot set registry" end private :check_registry def set_registry(v) #:nodoc: - raise InvalidURIError, "can not set registry" + raise InvalidURIError, "cannot set registry" end protected :set_registry def registry=(v) - raise InvalidURIError, "can not set registry" + raise InvalidURIError, "cannot set registry" end # @@ -866,7 +866,7 @@ def check_opaque(v) # hier_part = ( net_path | abs_path ) [ "?" query ] if @host || @port || @user || @path # userinfo = @user + ':' + @password raise InvalidURIError, - "can not set opaque with host, port, userinfo or path" + "cannot set opaque with host, port, userinfo or path" elsif v && parser.regexp[:OPAQUE] !~ v raise InvalidComponentError, "bad component(expected opaque component): #{v}" @@ -1235,7 +1235,7 @@ def route_from0(oth) return rel, rel end - # you can modify `rel', but can not `oth'. + # you can modify `rel', but cannot `oth'. return oth, rel end private :route_from0 @@ -1260,7 +1260,7 @@ def route_from0(oth) # #=> # # def route_from(oth) - # you can modify `rel', but can not `oth'. + # you can modify `rel', but cannot `oth'. begin oth, rel = route_from0(oth) rescue From 618e2bb640c3db69c8532187e8db6eba789239e6 Mon Sep 17 00:00:00 2001 From: Nikita Levchuk Date: Wed, 6 Nov 2024 15:08:47 +0100 Subject: [PATCH 30/92] lib/uri/mailto.rb (EMAIL_REGEXP): the local part should not contain leading or trailing dots --- lib/uri/mailto.rb | 2 +- test/uri/test_mailto.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/uri/mailto.rb b/lib/uri/mailto.rb index cb8024f..c5a5e4a 100644 --- a/lib/uri/mailto.rb +++ b/lib/uri/mailto.rb @@ -52,7 +52,7 @@ class MailTo < Generic HEADER_REGEXP = /\A(?(?:%\h\h|[!$'-.0-;@-Z_a-z~])*=(?:%\h\h|[!$'-.0-;@-Z_a-z~])*)(?:&\g)*\z/ # practical regexp for email address # https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address - EMAIL_REGEXP = /\A[a-zA-Z0-9.!\#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*\z/ + EMAIL_REGEXP = /\A[^.][a-zA-Z0-9.!\#$%&'*+\/=?^_`{|}~-]+[^.]@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*\z/ # :startdoc: # diff --git a/test/uri/test_mailto.rb b/test/uri/test_mailto.rb index e7d3142..d2e9648 100644 --- a/test/uri/test_mailto.rb +++ b/test/uri/test_mailto.rb @@ -148,6 +148,14 @@ def test_check_to assert_raise(URI::InvalidComponentError) do u.to = '@invalid.email' end + + assert_raise(URI::InvalidComponentError) do + u.to = '.hello@invalid.email' + end + + assert_raise(URI::InvalidComponentError) do + u.to = 'hello.@invalid.email' + end end def test_to_s From aab4e6ee73668786c6633c9bbc43c2a93e94c087 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Thu, 7 Nov 2024 15:50:57 +0900 Subject: [PATCH 31/92] Enabled trusted publisher for rubygems.org --- .github/workflows/push_gem.yml | 46 ++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/push_gem.yml diff --git a/.github/workflows/push_gem.yml b/.github/workflows/push_gem.yml new file mode 100644 index 0000000..e15d54b --- /dev/null +++ b/.github/workflows/push_gem.yml @@ -0,0 +1,46 @@ +name: Publish gem to rubygems.org + +on: + push: + tags: + - 'v*' + +permissions: + contents: read + +jobs: + push: + if: github.repository == 'ruby/uri' + runs-on: ubuntu-latest + + environment: + name: rubygems.org + url: https://rubygems.org/gems/uri + + permissions: + contents: write + id-token: write + + steps: + - name: Harden Runner + uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 + with: + egress-policy: audit + + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + + - name: Set up Ruby + uses: ruby/setup-ruby@a6e6f86333f0a2523ece813039b8b4be04560854 # v1.190.0 + with: + bundler-cache: true + ruby-version: ruby + + - name: Publish to RubyGems + uses: rubygems/release-gem@612653d273a73bdae1df8453e090060bb4db5f31 # v1 + + - name: Create GitHub release + run: | + tag_name="$(git describe --tags --abbrev=0)" + gh release create "${tag_name}" --verify-tag --generate-notes + env: + GITHUB_TOKEN: ${{ secrets.MATZBOT_GITHUB_WORKFLOW_TOKEN }} From af8d9d6bb1a90da71f64a9c3f8eddd3626d44efb Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Thu, 7 Nov 2024 15:52:18 +0900 Subject: [PATCH 32/92] Bump up v1.0.0 --- lib/uri/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/uri/version.rb b/lib/uri/version.rb index bfe3f47..c68c43a 100644 --- a/lib/uri/version.rb +++ b/lib/uri/version.rb @@ -1,6 +1,6 @@ module URI # :stopdoc: - VERSION_CODE = '001301'.freeze + VERSION_CODE = '010000'.freeze VERSION = VERSION_CODE.scan(/../).collect{|n| n.to_i}.join('.').freeze # :startdoc: end From 1f3d3df02a0ff764e9a8a80c8d9e2c1e2d11bdce Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Fri, 8 Nov 2024 15:05:58 +0900 Subject: [PATCH 33/92] Added more fallback constants like URI::PARTTERN and URI::REGEXP Fixed https://github.com/ruby/uri/issues/125 --- lib/uri/common.rb | 8 +++++++- test/uri/test_common.rb | 6 +++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/uri/common.rb b/lib/uri/common.rb index cf93fb1..fe8475f 100644 --- a/lib/uri/common.rb +++ b/lib/uri/common.rb @@ -46,9 +46,15 @@ def self.parser=(parser = RFC3986_PARSER) self.parser = RFC3986_PARSER def self.const_missing(const) - if value = RFC2396_PARSER.regexp[const] + if const == :REGEXP + warn "URI::REGEXP is obsolete. Use URI::RFC2396_REGEXP explicitly.", uplevel: 1 if $VERBOSE + URI::RFC2396_REGEXP + elsif value = RFC2396_PARSER.regexp[const] warn "URI::#{const} is obsolete. Use RFC2396_PARSER.regexp[#{const.inspect}] explicitly.", uplevel: 1 if $VERBOSE value + elsif value = RFC2396_Parser.const_get(const) + warn "URI::#{const} is obsolete. Use RFC2396_Parser::#{const} explicitly.", uplevel: 1 if $VERBOSE + value else super end diff --git a/test/uri/test_common.rb b/test/uri/test_common.rb index bccdeaf..176efb8 100644 --- a/test/uri/test_common.rb +++ b/test/uri/test_common.rb @@ -13,8 +13,12 @@ def teardown def test_fallback_constants orig_verbose = $VERBOSE $VERBOSE = nil - assert URI::ABS_URI + assert_raise(NameError) { URI::FOO } + + assert_equal URI::ABS_URI, URI::RFC2396_PARSER.regexp[:ABS_URI] + assert_equal URI::PATTERN, URI::RFC2396_Parser::PATTERN + assert_equal URI::REGEXP, URI::RFC2396_REGEXP ensure $VERBOSE = orig_verbose end From 3011eb6f6e53c7870f91404d4a789cb854c893ad Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Fri, 8 Nov 2024 15:07:36 +0900 Subject: [PATCH 34/92] Bump up v1.0.1 --- lib/uri/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/uri/version.rb b/lib/uri/version.rb index c68c43a..e74ddec 100644 --- a/lib/uri/version.rb +++ b/lib/uri/version.rb @@ -1,6 +1,6 @@ module URI # :stopdoc: - VERSION_CODE = '010000'.freeze + VERSION_CODE = '010001'.freeze VERSION = VERSION_CODE.scan(/../).collect{|n| n.to_i}.join('.').freeze # :startdoc: end From c191b627cbe5a8a735fd9e6f1eaa3b92ea901f43 Mon Sep 17 00:00:00 2001 From: Joe Rafaniello Date: Fri, 8 Nov 2024 11:57:18 -0500 Subject: [PATCH 35/92] Fix minor typo from 9997c1acee --- lib/uri/rfc3986_parser.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/uri/rfc3986_parser.rb b/lib/uri/rfc3986_parser.rb index 4000f13..0b5f0c4 100644 --- a/lib/uri/rfc3986_parser.rb +++ b/lib/uri/rfc3986_parser.rb @@ -142,25 +142,25 @@ def join(*uris) # :nodoc: # Compatibility for RFC2396 parser def extract(str, schemes = nil, &block) # :nodoc: - warn "URI::RFC3986_PARSER.extract is obsoleted. Use URI::RFC2396_PARSER.extract explicitly.", uplevel: 1 if $VERBOSE + warn "URI::RFC3986_PARSER.extract is obsolete. Use URI::RFC2396_PARSER.extract explicitly.", uplevel: 1 if $VERBOSE RFC2396_PARSER.extract(str, schemes, &block) end # Compatibility for RFC2396 parser def make_regexp(schemes = nil) # :nodoc: - warn "URI::RFC3986_PARSER.make_regexp is obsoleted. Use URI::RFC2396_PARSER.make_regexp explicitly.", uplevel: 1 if $VERBOSE + warn "URI::RFC3986_PARSER.make_regexp is obsolete. Use URI::RFC2396_PARSER.make_regexp explicitly.", uplevel: 1 if $VERBOSE RFC2396_PARSER.make_regexp(schemes) end # Compatibility for RFC2396 parser def escape(str, unsafe = nil) # :nodoc: - warn "URI::RFC3986_PARSER.escape is obsoleted. Use URI::RFC2396_PARSER.escape explicitly.", uplevel: 1 if $VERBOSE + warn "URI::RFC3986_PARSER.escape is obsolete. Use URI::RFC2396_PARSER.escape explicitly.", uplevel: 1 if $VERBOSE unsafe ? RFC2396_PARSER.escape(str, unsafe) : RFC2396_PARSER.escape(str) end # Compatibility for RFC2396 parser def unescape(str, escaped = nil) # :nodoc: - warn "URI::RFC3986_PARSER.unescape is obsoleted. Use URI::RFC2396_PARSER.unescape explicitly.", uplevel: 1 if $VERBOSE + warn "URI::RFC3986_PARSER.unescape is obsolete. Use URI::RFC2396_PARSER.unescape explicitly.", uplevel: 1 if $VERBOSE escaped ? RFC2396_PARSER.unescape(str, escaped) : RFC2396_PARSER.unescape(str) end From f0847c266cd5d427559a3bec1449fee6613e7d06 Mon Sep 17 00:00:00 2001 From: Orien Madgwick <497874+orien@users.noreply.github.com> Date: Mon, 11 Nov 2024 13:34:33 +1100 Subject: [PATCH 36/92] Remove unused files from the gem package --- uri.gemspec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/uri.gemspec b/uri.gemspec index 9cf0a71..9c4d43e 100644 --- a/uri.gemspec +++ b/uri.gemspec @@ -30,8 +30,11 @@ Gem::Specification.new do |spec| # Specify which files should be added to the gem when it is released. # The `git ls-files -z` loads the files in the RubyGem that have been added into git. + gemspec = File.basename(__FILE__) spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do - `git ls-files -z 2>#{IO::NULL}`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } + `git ls-files -z 2>#{IO::NULL}`.split("\x0").reject do |file| + (file == gemspec) || file.start_with?(*%w[bin/ test/ .github/ .gitignore Gemfile Rakefile]) + end end spec.bindir = "exe" spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } From ee9a38701a3d49b7d56f7e7a1fd846333186d748 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Wed, 13 Nov 2024 12:01:06 +0900 Subject: [PATCH 37/92] Restore constants like URI::REGEXP::PATTERN::IPV6ADDR --- lib/uri/rfc2396_parser.rb | 7 +++++++ test/uri/test_common.rb | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/lib/uri/rfc2396_parser.rb b/lib/uri/rfc2396_parser.rb index a56ca34..c112b1b 100644 --- a/lib/uri/rfc2396_parser.rb +++ b/lib/uri/rfc2396_parser.rb @@ -536,4 +536,11 @@ def convert_to_uri(uri) end end # class Parser + + # Backward compatibility for URI::REGEXP::PATTERN::* + RFC2396_Parser.new.pattern.each_pair do |sym, str| + unless RFC2396_REGEXP::PATTERN.const_defined?(sym) + RFC2396_REGEXP::PATTERN.const_set(sym, str) + end + end end # module URI diff --git a/test/uri/test_common.rb b/test/uri/test_common.rb index 176efb8..b1e3b2b 100644 --- a/test/uri/test_common.rb +++ b/test/uri/test_common.rb @@ -10,6 +10,10 @@ def setup def teardown end + class Foo + include URI::REGEXP::PATTERN + end + def test_fallback_constants orig_verbose = $VERBOSE $VERBOSE = nil @@ -19,6 +23,8 @@ def test_fallback_constants assert_equal URI::ABS_URI, URI::RFC2396_PARSER.regexp[:ABS_URI] assert_equal URI::PATTERN, URI::RFC2396_Parser::PATTERN assert_equal URI::REGEXP, URI::RFC2396_REGEXP + assert_equal URI::REGEXP::PATTERN, URI::RFC2396_REGEXP::PATTERN + assert_equal Foo::IPV4ADDR, URI::RFC2396_REGEXP::PATTERN::IPV4ADDR ensure $VERBOSE = orig_verbose end From 60a8bc15759065762fda95e83f383747904089a8 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Wed, 13 Nov 2024 12:02:46 +0900 Subject: [PATCH 38/92] Removed duplicated declare step for constants under the URI::RFC2396_REGEXP::PATTERN --- lib/uri/common.rb | 5 ----- test/uri/test_common.rb | 1 + 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/uri/common.rb b/lib/uri/common.rb index fe8475f..f13ff1a 100644 --- a/lib/uri/common.rb +++ b/lib/uri/common.rb @@ -31,11 +31,6 @@ def self.parser=(parser = RFC3986_PARSER) if Parser == RFC2396_Parser const_set("REGEXP", URI::RFC2396_REGEXP) const_set("PATTERN", URI::RFC2396_REGEXP::PATTERN) - Parser.new.pattern.each_pair do |sym, str| - unless REGEXP::PATTERN.const_defined?(sym) - REGEXP::PATTERN.const_set(sym, str) - end - end end Parser.new.regexp.each_pair do |sym, str| diff --git a/test/uri/test_common.rb b/test/uri/test_common.rb index b1e3b2b..e96f819 100644 --- a/test/uri/test_common.rb +++ b/test/uri/test_common.rb @@ -40,6 +40,7 @@ def test_parser_switch assert defined?(URI::REGEXP) assert defined?(URI::PATTERN) assert defined?(URI::PATTERN::ESCAPED) + assert defined?(URI::REGEXP::PATTERN::IPV6ADDR) URI.parser = URI::RFC3986_PARSER From a0dd612e9070c979f20ccf4308f6aa10690c1d68 Mon Sep 17 00:00:00 2001 From: Orien Madgwick <497874+orien@users.noreply.github.com> Date: Wed, 13 Nov 2024 15:20:46 +1100 Subject: [PATCH 39/92] Remove rakelib/ dir from gem also --- uri.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uri.gemspec b/uri.gemspec index 9c4d43e..0d0f897 100644 --- a/uri.gemspec +++ b/uri.gemspec @@ -33,7 +33,7 @@ Gem::Specification.new do |spec| gemspec = File.basename(__FILE__) spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do `git ls-files -z 2>#{IO::NULL}`.split("\x0").reject do |file| - (file == gemspec) || file.start_with?(*%w[bin/ test/ .github/ .gitignore Gemfile Rakefile]) + (file == gemspec) || file.start_with?(*%w[bin/ test/ rakelib/ .github/ .gitignore Gemfile Rakefile]) end end spec.bindir = "exe" From 57ee11f55f34bd89097fae12839d565b20fa6ca1 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Wed, 13 Nov 2024 14:03:06 +0900 Subject: [PATCH 40/92] Don't use bundle exec --- .github/workflows/gh-pages.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index f0e6b5d..1d70fe5 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -30,7 +30,7 @@ jobs: uses: actions/configure-pages@v5 - name: Build with RDoc # Outputs to the './_site' directory by default - run: bundle exec rake rdoc + run: rake rdoc - name: Upload artifact uses: actions/upload-pages-artifact@v3 From 0a042e862650f085bc7bc55f5a1cdcea52b486e4 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Wed, 13 Nov 2024 14:05:50 +0900 Subject: [PATCH 41/92] Fixed rake rdoc --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index 19de93e..3935fdf 100644 --- a/Rakefile +++ b/Rakefile @@ -11,7 +11,7 @@ require "rdoc/task" RDoc::Task.new do |doc| doc.main = "README.md" doc.title = "URI - handle Uniform Resource Identifiers" - doc.rdoc_files = FileList.new %w[lib README.md LICENSE.txt] + doc.rdoc_files = FileList.new %w[lib README.md BSDL COPYING] doc.rdoc_dir = "_site" # for github pages end From b6f583369a2c0f31a8aeff488d1e9c0bf05edac6 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Thu, 14 Nov 2024 11:58:08 +0900 Subject: [PATCH 42/92] Check existence constants only URI module --- lib/uri/common.rb | 2 +- lib/uri/rfc2396_parser.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/uri/common.rb b/lib/uri/common.rb index f13ff1a..c3fe0b4 100644 --- a/lib/uri/common.rb +++ b/lib/uri/common.rb @@ -34,7 +34,7 @@ def self.parser=(parser = RFC3986_PARSER) end Parser.new.regexp.each_pair do |sym, str| - remove_const(sym) if const_defined?(sym) + remove_const(sym) if const_defined?(sym, false) const_set(sym, str) end end diff --git a/lib/uri/rfc2396_parser.rb b/lib/uri/rfc2396_parser.rb index c112b1b..0336366 100644 --- a/lib/uri/rfc2396_parser.rb +++ b/lib/uri/rfc2396_parser.rb @@ -539,7 +539,7 @@ def convert_to_uri(uri) # Backward compatibility for URI::REGEXP::PATTERN::* RFC2396_Parser.new.pattern.each_pair do |sym, str| - unless RFC2396_REGEXP::PATTERN.const_defined?(sym) + unless RFC2396_REGEXP::PATTERN.const_defined?(sym, false) RFC2396_REGEXP::PATTERN.const_set(sym, str) end end From e46960a467f2ed398731286ec78b899e1a01655f Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Thu, 14 Nov 2024 12:48:33 +0900 Subject: [PATCH 43/92] Bump up v1.0.2 --- lib/uri/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/uri/version.rb b/lib/uri/version.rb index e74ddec..59f1c82 100644 --- a/lib/uri/version.rb +++ b/lib/uri/version.rb @@ -1,6 +1,6 @@ module URI # :stopdoc: - VERSION_CODE = '010001'.freeze + VERSION_CODE = '010002'.freeze VERSION = VERSION_CODE.scan(/../).collect{|n| n.to_i}.join('.').freeze # :startdoc: end From 0524ed1137b709ac75897e57abc9e9a85f1a1573 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Nov 2024 00:54:34 +0000 Subject: [PATCH 44/92] Bump step-security/harden-runner from 2.10.1 to 2.10.2 Bumps [step-security/harden-runner](https://github.com/step-security/harden-runner) from 2.10.1 to 2.10.2. - [Release notes](https://github.com/step-security/harden-runner/releases) - [Commits](https://github.com/step-security/harden-runner/compare/91182cccc01eb5e619899d80e4e971d6181294a7...0080882f6c36860b6ba35c610c98ce87d4e2f26f) --- updated-dependencies: - dependency-name: step-security/harden-runner dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/push_gem.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push_gem.yml b/.github/workflows/push_gem.yml index e15d54b..7f23d56 100644 --- a/.github/workflows/push_gem.yml +++ b/.github/workflows/push_gem.yml @@ -23,7 +23,7 @@ jobs: steps: - name: Harden Runner - uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 + uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 with: egress-policy: audit From ad3f10123ec4925efed33b2f9cd221a052391841 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Nov 2024 00:54:39 +0000 Subject: [PATCH 45/92] Bump rubygems/release-gem Bumps [rubygems/release-gem](https://github.com/rubygems/release-gem) from 612653d273a73bdae1df8453e090060bb4db5f31 to 9e85cb11501bebc2ae661c1500176316d3987059. - [Release notes](https://github.com/rubygems/release-gem/releases) - [Commits](https://github.com/rubygems/release-gem/compare/612653d273a73bdae1df8453e090060bb4db5f31...9e85cb11501bebc2ae661c1500176316d3987059) --- updated-dependencies: - dependency-name: rubygems/release-gem dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- .github/workflows/push_gem.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push_gem.yml b/.github/workflows/push_gem.yml index e15d54b..569997e 100644 --- a/.github/workflows/push_gem.yml +++ b/.github/workflows/push_gem.yml @@ -36,7 +36,7 @@ jobs: ruby-version: ruby - name: Publish to RubyGems - uses: rubygems/release-gem@612653d273a73bdae1df8453e090060bb4db5f31 # v1 + uses: rubygems/release-gem@9e85cb11501bebc2ae661c1500176316d3987059 # v1 - name: Create GitHub release run: | From be0a095cf8f8f8ce2d26c6b8ddd4b20e463f6521 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Mon, 25 Nov 2024 12:36:36 +0900 Subject: [PATCH 46/92] Fixed version number of rubygems/release-gem --- .github/workflows/push_gem.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push_gem.yml b/.github/workflows/push_gem.yml index 986bd7d..2f34c79 100644 --- a/.github/workflows/push_gem.yml +++ b/.github/workflows/push_gem.yml @@ -36,7 +36,7 @@ jobs: ruby-version: ruby - name: Publish to RubyGems - uses: rubygems/release-gem@9e85cb11501bebc2ae661c1500176316d3987059 # v1 + uses: rubygems/release-gem@9e85cb11501bebc2ae661c1500176316d3987059 # v1.1.0 - name: Create GitHub release run: | From c00726a20a006e3a81bee19650e7830213cfabad Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Mon, 25 Nov 2024 16:28:48 +0900 Subject: [PATCH 47/92] Prevent a warning: URI::REGEXP is obsolete (#138) --- test/uri/test_common.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/uri/test_common.rb b/test/uri/test_common.rb index e96f819..774eb91 100644 --- a/test/uri/test_common.rb +++ b/test/uri/test_common.rb @@ -11,7 +11,7 @@ def teardown end class Foo - include URI::REGEXP::PATTERN + include URI::RFC2396_REGEXP::PATTERN end def test_fallback_constants From 22f5a7a7906e347a49b7b888339d31825b31de4d Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Tue, 26 Nov 2024 10:32:51 +0900 Subject: [PATCH 48/92] Revert "Prevent a warning: URI::REGEXP is obsolete (#138)" This reverts commit c00726a20a006e3a81bee19650e7830213cfabad. --- test/uri/test_common.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/uri/test_common.rb b/test/uri/test_common.rb index 774eb91..e96f819 100644 --- a/test/uri/test_common.rb +++ b/test/uri/test_common.rb @@ -11,7 +11,7 @@ def teardown end class Foo - include URI::RFC2396_REGEXP::PATTERN + include URI::REGEXP::PATTERN end def test_fallback_constants From bd2e4be9d0fa4937efa7811a999f5820ea868a9f Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Tue, 26 Nov 2024 10:47:12 +0900 Subject: [PATCH 49/92] Suppress deprecate warning of test class and use EnvUtil.suppress_warning. --- test/uri/test_common.rb | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/test/uri/test_common.rb b/test/uri/test_common.rb index e96f819..1e28347 100644 --- a/test/uri/test_common.rb +++ b/test/uri/test_common.rb @@ -10,23 +10,20 @@ def setup def teardown end - class Foo - include URI::REGEXP::PATTERN - end - - def test_fallback_constants - orig_verbose = $VERBOSE - $VERBOSE = nil + EnvUtil.suppress_warning do + class Foo + include URI::REGEXP::PATTERN + end - assert_raise(NameError) { URI::FOO } + def test_fallback_constants + assert_raise(NameError) { URI::FOO } - assert_equal URI::ABS_URI, URI::RFC2396_PARSER.regexp[:ABS_URI] - assert_equal URI::PATTERN, URI::RFC2396_Parser::PATTERN - assert_equal URI::REGEXP, URI::RFC2396_REGEXP - assert_equal URI::REGEXP::PATTERN, URI::RFC2396_REGEXP::PATTERN - assert_equal Foo::IPV4ADDR, URI::RFC2396_REGEXP::PATTERN::IPV4ADDR - ensure - $VERBOSE = orig_verbose + assert_equal URI::ABS_URI, URI::RFC2396_PARSER.regexp[:ABS_URI] + assert_equal URI::PATTERN, URI::RFC2396_Parser::PATTERN + assert_equal URI::REGEXP, URI::RFC2396_REGEXP + assert_equal URI::REGEXP::PATTERN, URI::RFC2396_REGEXP::PATTERN + assert_equal Foo::IPV4ADDR, URI::RFC2396_REGEXP::PATTERN::IPV4ADDR + end end def test_parser_switch From bdf765e44a51d725d7189d7e8343ce807410aee6 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Tue, 26 Nov 2024 19:02:53 +0900 Subject: [PATCH 50/92] Suppress deprecate warning of test class (retry) (#140) A follow-up to bd2e4be9d0fa4937efa7811a999f5820ea868a9f Also, leave a comment that the use of `URI::REGEXP` is intentional --- test/uri/test_common.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/uri/test_common.rb b/test/uri/test_common.rb index 1e28347..6326aec 100644 --- a/test/uri/test_common.rb +++ b/test/uri/test_common.rb @@ -12,10 +12,13 @@ def teardown EnvUtil.suppress_warning do class Foo + # Intentionally use `URI::REGEXP`, which is for the compatibility include URI::REGEXP::PATTERN end + end - def test_fallback_constants + def test_fallback_constants + EnvUtil.suppress_warning do assert_raise(NameError) { URI::FOO } assert_equal URI::ABS_URI, URI::RFC2396_PARSER.regexp[:ABS_URI] From 2d7d2d9988c2a2438a47525ad48ee2481e344eb8 Mon Sep 17 00:00:00 2001 From: Nikita Levchuk Date: Fri, 6 Dec 2024 11:56:03 +0100 Subject: [PATCH 51/92] lib/uri/mailto.rb (EMAIL_REGEXP): use assertions surrounding the local part instead of a character class --- lib/uri/mailto.rb | 2 +- test/uri/test_mailto.rb | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/uri/mailto.rb b/lib/uri/mailto.rb index c5a5e4a..a15d2f0 100644 --- a/lib/uri/mailto.rb +++ b/lib/uri/mailto.rb @@ -52,7 +52,7 @@ class MailTo < Generic HEADER_REGEXP = /\A(?(?:%\h\h|[!$'-.0-;@-Z_a-z~])*=(?:%\h\h|[!$'-.0-;@-Z_a-z~])*)(?:&\g)*\z/ # practical regexp for email address # https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address - EMAIL_REGEXP = /\A[^.][a-zA-Z0-9.!\#$%&'*+\/=?^_`{|}~-]+[^.]@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*\z/ + EMAIL_REGEXP = /\A(?!\.)[a-zA-Z0-9.!\#$%&'*+\/=?^_`{|}~-]+(? Date: Mon, 16 Dec 2024 15:17:53 +0900 Subject: [PATCH 52/92] Now, URI library uses RFC3986 parser as default --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3775f3b..5c7c0dd 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![CI](https://github.com/ruby/uri/actions/workflows/test.yml/badge.svg)](https://github.com/ruby/uri/actions/workflows/test.yml) [![Yard Docs](https://img.shields.io/badge/docs-exist-blue.svg)](https://ruby.github.io/uri/) -URI is a module providing classes to handle Uniform Resource Identifiers [RFC2396](http://tools.ietf.org/html/rfc2396). +URI is a module providing classes to handle Uniform Resource Identifiers [RFC3986](http://tools.ietf.org/html/rfc3986). ## Features From 9ea0783d321793dcb6563d9fb1dbea2cba3523af Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 Dec 2024 00:58:54 +0000 Subject: [PATCH 53/92] Bump rubygems/release-gem from 1.1.0 to 1.1.1 Bumps [rubygems/release-gem](https://github.com/rubygems/release-gem) from 1.1.0 to 1.1.1. - [Release notes](https://github.com/rubygems/release-gem/releases) - [Commits](https://github.com/rubygems/release-gem/compare/9e85cb11501bebc2ae661c1500176316d3987059...a25424ba2ba8b387abc8ef40807c2c85b96cbe32) --- updated-dependencies: - dependency-name: rubygems/release-gem dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/push_gem.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push_gem.yml b/.github/workflows/push_gem.yml index 2f34c79..74d6d2a 100644 --- a/.github/workflows/push_gem.yml +++ b/.github/workflows/push_gem.yml @@ -36,7 +36,7 @@ jobs: ruby-version: ruby - name: Publish to RubyGems - uses: rubygems/release-gem@9e85cb11501bebc2ae661c1500176316d3987059 # v1.1.0 + uses: rubygems/release-gem@a25424ba2ba8b387abc8ef40807c2c85b96cbe32 # v1.1.1 - name: Create GitHub release run: | From f7589d5f622afe9790ed1cc266326a9911bbc0df Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2025 00:39:23 +0000 Subject: [PATCH 54/92] Bump step-security/harden-runner from 2.10.2 to 2.10.3 Bumps [step-security/harden-runner](https://github.com/step-security/harden-runner) from 2.10.2 to 2.10.3. - [Release notes](https://github.com/step-security/harden-runner/releases) - [Commits](https://github.com/step-security/harden-runner/compare/0080882f6c36860b6ba35c610c98ce87d4e2f26f...c95a14d0e5bab51a9f56296a4eb0e416910cd350) --- updated-dependencies: - dependency-name: step-security/harden-runner dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/push_gem.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push_gem.yml b/.github/workflows/push_gem.yml index 74d6d2a..9ae544e 100644 --- a/.github/workflows/push_gem.yml +++ b/.github/workflows/push_gem.yml @@ -23,7 +23,7 @@ jobs: steps: - name: Harden Runner - uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 + uses: step-security/harden-runner@c95a14d0e5bab51a9f56296a4eb0e416910cd350 # v2.10.3 with: egress-policy: audit From 7e2142f49d03539df63f5e92e98390d9f1f6ff6c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 Jan 2025 00:59:42 +0000 Subject: [PATCH 55/92] Bump step-security/harden-runner from 2.10.3 to 2.10.4 Bumps [step-security/harden-runner](https://github.com/step-security/harden-runner) from 2.10.3 to 2.10.4. - [Release notes](https://github.com/step-security/harden-runner/releases) - [Commits](https://github.com/step-security/harden-runner/compare/c95a14d0e5bab51a9f56296a4eb0e416910cd350...cb605e52c26070c328afc4562f0b4ada7618a84e) --- updated-dependencies: - dependency-name: step-security/harden-runner dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/push_gem.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push_gem.yml b/.github/workflows/push_gem.yml index 9ae544e..5ce7869 100644 --- a/.github/workflows/push_gem.yml +++ b/.github/workflows/push_gem.yml @@ -23,7 +23,7 @@ jobs: steps: - name: Harden Runner - uses: step-security/harden-runner@c95a14d0e5bab51a9f56296a4eb0e416910cd350 # v2.10.3 + uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4 with: egress-policy: audit From fec924238f8bb16871efbe4d8dfa022e5d54db41 Mon Sep 17 00:00:00 2001 From: Yuji Yaginuma Date: Thu, 23 Jan 2025 17:44:17 +0900 Subject: [PATCH 56/92] Fix the mention to removed `URI.escape/URI::Escape` This was removed by #9. --- lib/uri/file.rb | 2 +- lib/uri/generic.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/uri/file.rb b/lib/uri/file.rb index 940d361..47b5aef 100644 --- a/lib/uri/file.rb +++ b/lib/uri/file.rb @@ -47,7 +47,7 @@ class File < Generic # :path => '/ruby/src'}) # uri2.to_s # => "file://host.example.com/ruby/src" # - # uri3 = URI::File.build({:path => URI::escape('/path/my file.txt')}) + # uri3 = URI::File.build({:path => URI::RFC2396_PARSER.escape('/path/my file.txt')}) # uri3.to_s # => "file:///path/my%20file.txt" # def self.build(args) diff --git a/lib/uri/generic.rb b/lib/uri/generic.rb index d4bfa3b..07346c6 100644 --- a/lib/uri/generic.rb +++ b/lib/uri/generic.rb @@ -73,7 +73,7 @@ def self.use_registry # :nodoc: # # At first, tries to create a new URI::Generic instance using # URI::Generic::build. But, if exception URI::InvalidComponentError is raised, - # then it does URI::Escape.escape all URI components and tries again. + # then it does URI::RFC2396_PARSER.escape all URI components and tries again. # def self.build2(args) begin From aa45e72407f7e0da35cdf890f5bad73da2284ece Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 23 Jan 2025 22:50:41 +0900 Subject: [PATCH 57/92] [DOC] Add config files for RDoc --- .document | 4 ++++ .rdoc_options | 4 ++++ 2 files changed, 8 insertions(+) create mode 100644 .document create mode 100644 .rdoc_options diff --git a/.document b/.document new file mode 100644 index 0000000..e2b9569 --- /dev/null +++ b/.document @@ -0,0 +1,4 @@ +BSDL +COPYING +README.md +lib/ diff --git a/.rdoc_options b/.rdoc_options new file mode 100644 index 0000000..b1f9cda --- /dev/null +++ b/.rdoc_options @@ -0,0 +1,4 @@ +main_page: README.md +op_dir: _site +warn_missing_rdoc_ref: true +title: URI Documentation From fe7aa3dac2b3415758635a616ce44afb15bf4900 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 23 Jan 2025 22:55:31 +0900 Subject: [PATCH 58/92] [DOC] Make documentation 100% --- .document | 1 + docs/kernel.rb | 2 ++ lib/uri/common.rb | 10 +++++++--- lib/uri/generic.rb | 8 +++++--- lib/uri/rfc2396_parser.rb | 12 ++++++------ 5 files changed, 21 insertions(+), 12 deletions(-) create mode 100644 docs/kernel.rb diff --git a/.document b/.document index e2b9569..1d07bdf 100644 --- a/.document +++ b/.document @@ -1,4 +1,5 @@ BSDL COPYING README.md +docs/ lib/ diff --git a/docs/kernel.rb b/docs/kernel.rb new file mode 100644 index 0000000..68ed335 --- /dev/null +++ b/docs/kernel.rb @@ -0,0 +1,2 @@ +# :stopdoc: +module Kernel end diff --git a/lib/uri/common.rb b/lib/uri/common.rb index c3fe0b4..bf28dea 100644 --- a/lib/uri/common.rb +++ b/lib/uri/common.rb @@ -13,15 +13,19 @@ require_relative "rfc3986_parser" module URI + # The default parser instance for RFC 2396. RFC2396_PARSER = RFC2396_Parser.new Ractor.make_shareable(RFC2396_PARSER) if defined?(Ractor) + # The default parser instance for RFC 3986. RFC3986_PARSER = RFC3986_Parser.new Ractor.make_shareable(RFC3986_PARSER) if defined?(Ractor) + # The default parser instance. DEFAULT_PARSER = RFC3986_PARSER Ractor.make_shareable(DEFAULT_PARSER) if defined?(Ractor) + # Set the default parser instance. def self.parser=(parser = RFC3986_PARSER) remove_const(:Parser) if defined?(::URI::Parser) const_set("Parser", parser.class) @@ -40,7 +44,7 @@ def self.parser=(parser = RFC3986_PARSER) end self.parser = RFC3986_PARSER - def self.const_missing(const) + def self.const_missing(const) # :nodoc: if const == :REGEXP warn "URI::REGEXP is obsolete. Use URI::RFC2396_REGEXP explicitly.", uplevel: 1 if $VERBOSE URI::RFC2396_REGEXP @@ -87,7 +91,7 @@ def make_components_hash(klass, array_hash) module_function :make_components_hash end - module Schemes + module Schemes # :nodoc: end private_constant :Schemes @@ -305,7 +309,7 @@ def self.regexp(schemes = nil)# :nodoc: 256.times do |i| TBLENCWWWCOMP_[-i.chr] = -('%%%02X' % i) end - TBLENCURICOMP_ = TBLENCWWWCOMP_.dup.freeze + TBLENCURICOMP_ = TBLENCWWWCOMP_.dup.freeze # :nodoc: TBLENCWWWCOMP_[' '] = '+' TBLENCWWWCOMP_.freeze TBLDECWWWCOMP_ = {} # :nodoc: diff --git a/lib/uri/generic.rb b/lib/uri/generic.rb index d4bfa3b..f5cdb73 100644 --- a/lib/uri/generic.rb +++ b/lib/uri/generic.rb @@ -737,12 +737,12 @@ def check_registry(v) # :nodoc: end private :check_registry - def set_registry(v) #:nodoc: + def set_registry(v) # :nodoc: raise InvalidURIError, "cannot set registry" end protected :set_registry - def registry=(v) + def registry=(v) # :nodoc: raise InvalidURIError, "cannot set registry" end @@ -1392,10 +1392,12 @@ def ==(oth) end end + # Returns the hash value. def hash self.component_ary.hash end + # Compares with _oth_ for Hash. def eql?(oth) self.class == oth.class && parser == oth.parser && @@ -1438,7 +1440,7 @@ def select(*components) end end - def inspect + def inspect # :nodoc: "#<#{self.class} #{self}>" end diff --git a/lib/uri/rfc2396_parser.rb b/lib/uri/rfc2396_parser.rb index 0336366..75a2d2d 100644 --- a/lib/uri/rfc2396_parser.rb +++ b/lib/uri/rfc2396_parser.rb @@ -321,14 +321,14 @@ def unescape(str, escaped = @regexp[:ESCAPED]) str.gsub(escaped) { [$&[1, 2]].pack('H2').force_encoding(enc) } end - @@to_s = Kernel.instance_method(:to_s) - if @@to_s.respond_to?(:bind_call) - def inspect - @@to_s.bind_call(self) + TO_S = Kernel.instance_method(:to_s) # :nodoc: + if TO_S.respond_to?(:bind_call) + def inspect # :nodoc: + TO_S.bind_call(self) end else - def inspect - @@to_s.bind(self).call + def inspect # :nodoc: + TO_S.bind(self).call end end From 428eb10e44dd2ca3dee80bbc9ab774259a65286a Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Sun, 2 Feb 2025 16:11:09 +0900 Subject: [PATCH 59/92] Use a fully qualified name in warning messages Currently, some warning messages don't contain a `URI` like the following. ```ruby warning: URI::ABS_URI is obsolete. Use RFC2396_PARSER.regexp[:ABS_URI] explicitly. ``` But, without `URI` prefix, the suggested value doesn't work. So I think we should use a fully qualified name to avoid confusion. --- lib/uri/common.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/uri/common.rb b/lib/uri/common.rb index bf28dea..db19e8e 100644 --- a/lib/uri/common.rb +++ b/lib/uri/common.rb @@ -49,10 +49,10 @@ def self.const_missing(const) # :nodoc: warn "URI::REGEXP is obsolete. Use URI::RFC2396_REGEXP explicitly.", uplevel: 1 if $VERBOSE URI::RFC2396_REGEXP elsif value = RFC2396_PARSER.regexp[const] - warn "URI::#{const} is obsolete. Use RFC2396_PARSER.regexp[#{const.inspect}] explicitly.", uplevel: 1 if $VERBOSE + warn "URI::#{const} is obsolete. Use URI::RFC2396_PARSER.regexp[#{const.inspect}] explicitly.", uplevel: 1 if $VERBOSE value elsif value = RFC2396_Parser.const_get(const) - warn "URI::#{const} is obsolete. Use RFC2396_Parser::#{const} explicitly.", uplevel: 1 if $VERBOSE + warn "URI::#{const} is obsolete. Use URI::RFC2396_Parser::#{const} explicitly.", uplevel: 1 if $VERBOSE value else super From c0594630f0219ffb48f1f2a9bd2621ecf055b39b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Feb 2025 00:32:40 +0000 Subject: [PATCH 60/92] Bump step-security/harden-runner from 2.10.4 to 2.11.0 Bumps [step-security/harden-runner](https://github.com/step-security/harden-runner) from 2.10.4 to 2.11.0. - [Release notes](https://github.com/step-security/harden-runner/releases) - [Commits](https://github.com/step-security/harden-runner/compare/cb605e52c26070c328afc4562f0b4ada7618a84e...4d991eb9b905ef189e4c376166672c3f2f230481) --- updated-dependencies: - dependency-name: step-security/harden-runner dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/push_gem.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push_gem.yml b/.github/workflows/push_gem.yml index 5ce7869..9eb2e2a 100644 --- a/.github/workflows/push_gem.yml +++ b/.github/workflows/push_gem.yml @@ -23,7 +23,7 @@ jobs: steps: - name: Harden Runner - uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4 + uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0 with: egress-policy: audit From 3675494839112b64d5f082a9068237b277ed1495 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Fri, 21 Feb 2025 16:29:36 +0900 Subject: [PATCH 61/92] Truncate userinfo with URI#join, URI#merge and URI#+ --- lib/uri/generic.rb | 6 +++++- test/uri/test_generic.rb | 11 +++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/uri/generic.rb b/lib/uri/generic.rb index f5cdb73..cd3aa23 100644 --- a/lib/uri/generic.rb +++ b/lib/uri/generic.rb @@ -1141,7 +1141,11 @@ def merge(oth) end # RFC2396, Section 5.2, 7) - base.set_userinfo(rel.userinfo) if rel.userinfo + if rel.userinfo + base.set_userinfo(rel.userinfo) + else + base.set_userinfo(nil) + end base.set_host(rel.host) if rel.host base.set_port(rel.port) if rel.port base.query = rel.query if rel.query diff --git a/test/uri/test_generic.rb b/test/uri/test_generic.rb index 8209363..4b04998 100644 --- a/test/uri/test_generic.rb +++ b/test/uri/test_generic.rb @@ -175,6 +175,17 @@ def test_parse # must be empty string to identify as path-abempty, not path-absolute assert_equal('', url.host) assert_equal('http:////example.com', url.to_s) + + # sec-2957667 + url = URI.parse('http://user:pass@example.com').merge('//example.net') + assert_equal('http://example.net', url.to_s) + assert_nil(url.userinfo) + url = URI.join('http://user:pass@example.com', '//example.net') + assert_equal('http://example.net', url.to_s) + assert_nil(url.userinfo) + url = URI.parse('http://user:pass@example.com') + '//example.net' + assert_equal('http://example.net', url.to_s) + assert_nil(url.userinfo) end def test_parse_scheme_with_symbols From 2789182478f42ccbb62197f952eb730e4f02bfc5 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Fri, 21 Feb 2025 18:16:28 +0900 Subject: [PATCH 62/92] Fix merger of URI with authority component https://hackerone.com/reports/2957667 Co-authored-by: Nobuyoshi Nakada --- lib/uri/generic.rb | 19 +++++++------------ test/uri/test_generic.rb | 7 +++++++ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/lib/uri/generic.rb b/lib/uri/generic.rb index cd3aa23..b574104 100644 --- a/lib/uri/generic.rb +++ b/lib/uri/generic.rb @@ -1133,21 +1133,16 @@ def merge(oth) base.fragment=(nil) # RFC2396, Section 5.2, 4) - if !authority - base.set_path(merge_path(base.path, rel.path)) if base.path && rel.path - else - # RFC2396, Section 5.2, 4) - base.set_path(rel.path) if rel.path + if authority + base.set_userinfo(rel.userinfo) + base.set_host(rel.host) + base.set_port(rel.port || base.default_port) + base.set_path(rel.path) + elsif base.path && rel.path + base.set_path(merge_path(base.path, rel.path)) end # RFC2396, Section 5.2, 7) - if rel.userinfo - base.set_userinfo(rel.userinfo) - else - base.set_userinfo(nil) - end - base.set_host(rel.host) if rel.host - base.set_port(rel.port) if rel.port base.query = rel.query if rel.query base.fragment=(rel.fragment) if rel.fragment diff --git a/test/uri/test_generic.rb b/test/uri/test_generic.rb index 4b04998..1d5fbc7 100644 --- a/test/uri/test_generic.rb +++ b/test/uri/test_generic.rb @@ -278,6 +278,13 @@ def test_merge assert_equal(u0, u1) end + def test_merge_authority + u = URI.parse('http://user:pass@example.com:8080') + u0 = URI.parse('http://new.example.org/path') + u1 = u.merge('//new.example.org/path') + assert_equal(u0, u1) + end + def test_route url = URI.parse('http://hoge/a.html').route_to('http://hoge/b.html') assert_equal('b.html', url.to_s) From 3213f4a0f80f10c8f36993dbb9eabe7f2c1b50fd Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Wed, 26 Feb 2025 16:12:46 +0900 Subject: [PATCH 63/92] Bump up v1.0.3 --- lib/uri/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/uri/version.rb b/lib/uri/version.rb index 59f1c82..b6a8ce1 100644 --- a/lib/uri/version.rb +++ b/lib/uri/version.rb @@ -1,6 +1,6 @@ module URI # :stopdoc: - VERSION_CODE = '010002'.freeze + VERSION_CODE = '010003'.freeze VERSION = VERSION_CODE.scan(/../).collect{|n| n.to_i}.join('.').freeze # :startdoc: end From 602e2b347a6ee1642cc04ed8d5659a03814d3762 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Thu, 27 Feb 2025 11:11:37 +0900 Subject: [PATCH 64/92] Update to use the latest version of setup-ruby and bump up to Ruby 3.4 --- .github/workflows/gh-pages.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index 1d70fe5..e7ee429 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -21,9 +21,9 @@ jobs: - name: Checkout uses: actions/checkout@v4 - name: Setup Ruby - uses: ruby/setup-ruby@250fcd6a742febb1123a77a841497ccaa8b9e939 # v1.152.0 + uses: ruby/setup-ruby@32110d4e311bd8996b2a82bf2a43b714ccc91777 # v1.221.0 with: - ruby-version: '3.3' + ruby-version: '3.4' bundler-cache: true - name: Setup Pages id: pages From 38ea6c6f5fceb264d2e4aaed0c1ad2c0e65b1a03 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Apr 2025 00:06:13 +0000 Subject: [PATCH 65/92] Bump step-security/harden-runner from 2.11.0 to 2.11.1 Bumps [step-security/harden-runner](https://github.com/step-security/harden-runner) from 2.11.0 to 2.11.1. - [Release notes](https://github.com/step-security/harden-runner/releases) - [Commits](https://github.com/step-security/harden-runner/compare/4d991eb9b905ef189e4c376166672c3f2f230481...c6295a65d1254861815972266d5933fd6e532bdf) --- updated-dependencies: - dependency-name: step-security/harden-runner dependency-version: 2.11.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/push_gem.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push_gem.yml b/.github/workflows/push_gem.yml index 9eb2e2a..5779c20 100644 --- a/.github/workflows/push_gem.yml +++ b/.github/workflows/push_gem.yml @@ -23,7 +23,7 @@ jobs: steps: - name: Harden Runner - uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0 + uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1 with: egress-policy: audit From 917be23dee555ebadb54ac6a932e0c719609d095 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 28 Apr 2025 00:35:26 +0000 Subject: [PATCH 66/92] Bump step-security/harden-runner from 2.11.1 to 2.12.0 Bumps [step-security/harden-runner](https://github.com/step-security/harden-runner) from 2.11.1 to 2.12.0. - [Release notes](https://github.com/step-security/harden-runner/releases) - [Commits](https://github.com/step-security/harden-runner/compare/c6295a65d1254861815972266d5933fd6e532bdf...0634a2670c59f64b4a01f0f96f84700a4088b9f0) --- updated-dependencies: - dependency-name: step-security/harden-runner dependency-version: 2.12.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/push_gem.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push_gem.yml b/.github/workflows/push_gem.yml index 5779c20..df5b8d5 100644 --- a/.github/workflows/push_gem.yml +++ b/.github/workflows/push_gem.yml @@ -23,7 +23,7 @@ jobs: steps: - name: Harden Runner - uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1 + uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 with: egress-policy: audit From 324a7d5e2fef3c2304af6883100fcad2c503d0ef Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Tue, 27 May 2025 03:58:04 +0900 Subject: [PATCH 67/92] `Ractor::Port` * Added `Ractor::Port` * `Ractor::Port#receive` (support multi-threads) * `Rcator::Port#close` * `Ractor::Port#closed?` * Added some methods * `Ractor#join` * `Ractor#value` * `Ractor#monitor` * `Ractor#unmonitor` * Removed some methods * `Ractor#take` * `Ractor.yield` * Change the spec * `Racotr.select` You can wait for multiple sequences of messages with `Ractor::Port`. ```ruby ports = 3.times.map{ Ractor::Port.new } ports.map.with_index do |port, ri| Ractor.new port,ri do |port, ri| 3.times{|i| port << "r#{ri}-#{i}"} end end p ports.each{|port| pp 3.times.map{port.receive}} ``` In this example, we use 3 ports, and 3 Ractors send messages to them respectively. We can receive a series of messages from each port. You can use `Ractor#value` to get the last value of a Ractor's block: ```ruby result = Ractor.new do heavy_task() end.value ``` You can wait for the termination of a Ractor with `Ractor#join` like this: ```ruby Ractor.new do some_task() end.join ``` `#value` and `#join` are similar to `Thread#value` and `Thread#join`. To implement `#join`, `Ractor#monitor` (and `Ractor#unmonitor`) is introduced. This commit changes `Ractor.select()` method. It now only accepts ports or Ractors, and returns when a port receives a message or a Ractor terminates. We removes `Ractor.yield` and `Ractor#take` because: * `Ractor::Port` supports most of similar use cases in a simpler manner. * Removing them significantly simplifies the code. We also change the internal thread scheduler code (thread_pthread.c): * During barrier synchronization, we keep the `ractor_sched` lock to avoid deadlocks. This lock is released by `rb_ractor_sched_barrier_end()` which is called at the end of operations that require the barrier. * fix potential deadlock issues by checking interrupts just before setting UBF. https://bugs.ruby-lang.org/issues/21262 --- test/uri/test_common.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/uri/test_common.rb b/test/uri/test_common.rb index 6326aec..fef785a 100644 --- a/test/uri/test_common.rb +++ b/test/uri/test_common.rb @@ -75,7 +75,7 @@ def test_ractor return unless defined?(Ractor) assert_ractor(<<~RUBY, require: 'uri') r = Ractor.new { URI.parse("https://ruby-lang.org/").inspect } - assert_equal(URI.parse("https://ruby-lang.org/").inspect, r.take) + assert_equal(URI.parse("https://ruby-lang.org/").inspect, r.value) RUBY end From 443ed0cf8540588b3e4e9bf8b52cb8834f13c8bc Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Tue, 3 Jun 2025 16:55:28 +0900 Subject: [PATCH 68/92] Alias value or join to take in old Ruby --- test/uri/test_common.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/uri/test_common.rb b/test/uri/test_common.rb index fef785a..fef3f70 100644 --- a/test/uri/test_common.rb +++ b/test/uri/test_common.rb @@ -74,6 +74,9 @@ def test_extract def test_ractor return unless defined?(Ractor) assert_ractor(<<~RUBY, require: 'uri') + class Ractor + alias value take unless method_defined? :value # compat with Ruby 3.4 and olders + end r = Ractor.new { URI.parse("https://ruby-lang.org/").inspect } assert_equal(URI.parse("https://ruby-lang.org/").inspect, r.value) RUBY From 40e94cac119c309d3c25416351471cbb7ff5cb23 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Wed, 4 Jun 2025 14:32:51 +0900 Subject: [PATCH 69/92] Use the latest version of assert_ractor for Ractor#value --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index ba909e8..6669eae 100644 --- a/Gemfile +++ b/Gemfile @@ -6,5 +6,5 @@ group :development do gem "bundler" gem "rake" gem "test-unit" - gem "test-unit-ruby-core" + gem "test-unit-ruby-core", ">= 1.0.7" end From 9e51838a04713b6cf21e9de9ccaf919884ef56f6 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Wed, 4 Jun 2025 14:33:00 +0900 Subject: [PATCH 70/92] Revert "Alias value or join to take in old Ruby" This reverts commit 443ed0cf8540588b3e4e9bf8b52cb8834f13c8bc. --- test/uri/test_common.rb | 3 --- 1 file changed, 3 deletions(-) diff --git a/test/uri/test_common.rb b/test/uri/test_common.rb index fef3f70..fef785a 100644 --- a/test/uri/test_common.rb +++ b/test/uri/test_common.rb @@ -74,9 +74,6 @@ def test_extract def test_ractor return unless defined?(Ractor) assert_ractor(<<~RUBY, require: 'uri') - class Ractor - alias value take unless method_defined? :value # compat with Ruby 3.4 and olders - end r = Ractor.new { URI.parse("https://ruby-lang.org/").inspect } assert_equal(URI.parse("https://ruby-lang.org/").inspect, r.value) RUBY From 6aef020b8ce6ee35747f37635797b22935cfd753 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Jun 2025 00:50:46 +0000 Subject: [PATCH 71/92] Bump step-security/harden-runner from 2.12.0 to 2.12.1 Bumps [step-security/harden-runner](https://github.com/step-security/harden-runner) from 2.12.0 to 2.12.1. - [Release notes](https://github.com/step-security/harden-runner/releases) - [Commits](https://github.com/step-security/harden-runner/compare/0634a2670c59f64b4a01f0f96f84700a4088b9f0...002fdce3c6a235733a90a27c80493a3241e56863) --- updated-dependencies: - dependency-name: step-security/harden-runner dependency-version: 2.12.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/push_gem.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push_gem.yml b/.github/workflows/push_gem.yml index df5b8d5..9d20ae6 100644 --- a/.github/workflows/push_gem.yml +++ b/.github/workflows/push_gem.yml @@ -23,7 +23,7 @@ jobs: steps: - name: Harden Runner - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 + uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1 with: egress-policy: audit From d08f0efc2e539bc4c623157f28cc3a9851b06b8c Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Fri, 20 Jun 2025 13:42:45 +0900 Subject: [PATCH 72/92] Use GITHUB_TOKEN instead of admin credential --- .github/workflows/push_gem.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push_gem.yml b/.github/workflows/push_gem.yml index 9d20ae6..860d90e 100644 --- a/.github/workflows/push_gem.yml +++ b/.github/workflows/push_gem.yml @@ -43,4 +43,4 @@ jobs: tag_name="$(git describe --tags --abbrev=0)" gh release create "${tag_name}" --verify-tag --generate-notes env: - GITHUB_TOKEN: ${{ secrets.MATZBOT_GITHUB_WORKFLOW_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From d543c0dafa9221191a1844bb745f12faae297862 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 23 Jan 2025 21:19:20 +0900 Subject: [PATCH 73/92] Escape reserved characters in scheme name Fix #89 --- lib/uri/common.rb | 44 +++++++++++++++++++++++++++++++++-------- test/uri/test_common.rb | 21 ++++++++++---------- 2 files changed, 47 insertions(+), 18 deletions(-) diff --git a/lib/uri/common.rb b/lib/uri/common.rb index db19e8e..fb9a318 100644 --- a/lib/uri/common.rb +++ b/lib/uri/common.rb @@ -92,6 +92,38 @@ def make_components_hash(klass, array_hash) end module Schemes # :nodoc: + class << self + ReservedChars = ".+-" + EscapedChars = "\uFE52\uFE62\uFE63" + + def escape(name) + unless name and name.ascii_only? + return nil + end + name.upcase.tr(ReservedChars, EscapedChars) + end + + def unescape(name) + name.tr(EscapedChars, ReservedChars).encode(Encoding::US_ASCII).upcase + end + + def find(name) + const_get(name, false) if name and const_defined?(name, false) + end + + def register(name, klass) + unless scheme = escape(name) + raise ArgumentError, "invalid characater as scheme - #{name}" + end + const_set(scheme, klass) + end + + def list + constants.map { |name| + [unescape(name.to_s), const_get(name)] + }.to_h + end + end end private_constant :Schemes @@ -104,7 +136,7 @@ module Schemes # :nodoc: # Note that after calling String#upcase on +scheme+, it must be a valid # constant name. def self.register_scheme(scheme, klass) - Schemes.const_set(scheme.to_s.upcase, klass) + Schemes.register(scheme, klass) end # Returns a hash of the defined schemes: @@ -122,9 +154,7 @@ def self.register_scheme(scheme, klass) # # Related: URI.register_scheme. def self.scheme_list - Schemes.constants.map { |name| - [name.to_s.upcase, Schemes.const_get(name)] - }.to_h + Schemes.list end INITIAL_SCHEMES = scheme_list @@ -148,12 +178,10 @@ def self.scheme_list # # => # # def self.for(scheme, *arguments, default: Generic) - const_name = scheme.to_s.upcase + const_name = Schemes.escape(scheme) uri_class = INITIAL_SCHEMES[const_name] - uri_class ||= if /\A[A-Z]\w*\z/.match?(const_name) && Schemes.const_defined?(const_name, false) - Schemes.const_get(const_name, false) - end + uri_class ||= Schemes.find(const_name) uri_class ||= default return uri_class.new(scheme, *arguments) diff --git a/test/uri/test_common.rb b/test/uri/test_common.rb index fef785a..1291366 100644 --- a/test/uri/test_common.rb +++ b/test/uri/test_common.rb @@ -113,17 +113,18 @@ def test_register_scheme_lowercase def test_register_scheme_with_symbols # Valid schemes from https://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml - some_uri_class = Class.new(URI::Generic) - assert_raise(NameError) { URI.register_scheme 'ms-search', some_uri_class } - assert_raise(NameError) { URI.register_scheme 'microsoft.windows.camera', some_uri_class } - assert_raise(NameError) { URI.register_scheme 'coaps+ws', some_uri_class } + list = [] + %w[ms-search microsoft.windows.camera coaps+ws].each {|name| + list << [name, URI.register_scheme(name, Class.new(URI::Generic))] + } - ms_search_class = Class.new(URI::Generic) - URI.register_scheme 'MS_SEARCH', ms_search_class - begin - assert_equal URI::Generic, URI.parse('ms-search://localhost').class - ensure - URI.const_get(:Schemes).send(:remove_const, :MS_SEARCH) + list.each do |scheme, uri_class| + assert_equal uri_class, URI.parse("#{scheme}://localhost").class + end + ensure + schemes = URI.const_get(:Schemes) + list.each do |scheme, | + schemes.send(:remove_const, schemes.escape(scheme)) end end From 5531d42375571a34eea0449e6c306c0b12a16be2 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 23 Jan 2025 22:07:04 +0900 Subject: [PATCH 74/92] Use Lo category chars as escaped chars TruffleRuby does not allow Symbol categories as identifiers. --- lib/uri/common.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/uri/common.rb b/lib/uri/common.rb index fb9a318..ab02a64 100644 --- a/lib/uri/common.rb +++ b/lib/uri/common.rb @@ -94,7 +94,9 @@ def make_components_hash(klass, array_hash) module Schemes # :nodoc: class << self ReservedChars = ".+-" - EscapedChars = "\uFE52\uFE62\uFE63" + EscapedChars = "\u01C0\u01C1\u01C2" + # Use Lo category chars as escaped chars for TruffleRuby, which + # does not allow Symbol categories as identifiers. def escape(name) unless name and name.ascii_only? From b636e83d99d3e8d7237a964aea3a93fd710bb105 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 26 Jun 2025 10:33:05 +0900 Subject: [PATCH 75/92] Fix a typo Co-authored-by: Olle Jonsson --- lib/uri/common.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/uri/common.rb b/lib/uri/common.rb index ab02a64..b1a47cf 100644 --- a/lib/uri/common.rb +++ b/lib/uri/common.rb @@ -115,7 +115,7 @@ def find(name) def register(name, klass) unless scheme = escape(name) - raise ArgumentError, "invalid characater as scheme - #{name}" + raise ArgumentError, "invalid character as scheme - #{name}" end const_set(scheme, klass) end From 30212d311ec9ebbc7191e38b1d508ea5684d6c39 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sat, 25 Jan 2025 20:45:58 +0900 Subject: [PATCH 76/92] [DOC] State that uri library is needed to call Kernel#URI So that the example works as-is. --- lib/uri/common.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/uri/common.rb b/lib/uri/common.rb index b1a47cf..411a7e3 100644 --- a/lib/uri/common.rb +++ b/lib/uri/common.rb @@ -889,6 +889,7 @@ module Kernel # Returns a \URI object derived from the given +uri+, # which may be a \URI string or an existing \URI object: # + # require 'uri' # # Returns a new URI. # uri = URI('http://github.com/ruby/ruby') # # => # @@ -896,6 +897,8 @@ module Kernel # URI(uri) # # => # # + # You must require 'uri' to use this method. + # def URI(uri) if uri.is_a?(URI::Generic) uri From b69fe367ce914ef71200f339a9c6a8ec56e8933c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Jul 2025 00:13:35 +0000 Subject: [PATCH 77/92] Bump step-security/harden-runner from 2.12.1 to 2.12.2 Bumps [step-security/harden-runner](https://github.com/step-security/harden-runner) from 2.12.1 to 2.12.2. - [Release notes](https://github.com/step-security/harden-runner/releases) - [Commits](https://github.com/step-security/harden-runner/compare/002fdce3c6a235733a90a27c80493a3241e56863...6c439dc8bdf85cadbbce9ed30d1c7b959517bc49) --- updated-dependencies: - dependency-name: step-security/harden-runner dependency-version: 2.12.2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/push_gem.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push_gem.yml b/.github/workflows/push_gem.yml index 860d90e..df1e741 100644 --- a/.github/workflows/push_gem.yml +++ b/.github/workflows/push_gem.yml @@ -23,7 +23,7 @@ jobs: steps: - name: Harden Runner - uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1 + uses: step-security/harden-runner@6c439dc8bdf85cadbbce9ed30d1c7b959517bc49 # v2.12.2 with: egress-policy: audit From d79b3f5b94758aec360c846b6f7fd002c3a4baef Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 8 Jul 2025 17:57:49 +0900 Subject: [PATCH 78/92] Prefer dedicated assertion methods --- test/uri/test_ftp.rb | 10 +++++----- test/uri/test_generic.rb | 40 ++++++++++++++++++++-------------------- test/uri/test_http.rb | 16 ++++++++-------- test/uri/test_parser.rb | 18 +++++++++--------- test/uri/test_ws.rb | 16 ++++++++-------- test/uri/test_wss.rb | 16 ++++++++-------- 6 files changed, 58 insertions(+), 58 deletions(-) diff --git a/test/uri/test_ftp.rb b/test/uri/test_ftp.rb index f45bb06..3ad7864 100644 --- a/test/uri/test_ftp.rb +++ b/test/uri/test_ftp.rb @@ -33,11 +33,11 @@ def test_paths # If you think what's below is wrong, please read RubyForge bug 2055, # RFC 1738 section 3.2.2, and RFC 2396. u = URI.parse('ftp://ftp.example.com/foo/bar/file.ext') - assert(u.path == 'foo/bar/file.ext') + assert_equal('foo/bar/file.ext', u.path) u = URI.parse('ftp://ftp.example.com//foo/bar/file.ext') - assert(u.path == '/foo/bar/file.ext') + assert_equal('/foo/bar/file.ext', u.path) u = URI.parse('ftp://ftp.example.com/%2Ffoo/bar/file.ext') - assert(u.path == '/foo/bar/file.ext') + assert_equal('/foo/bar/file.ext', u.path) end def test_assemble @@ -45,8 +45,8 @@ def test_assemble # assuming everyone else has implemented RFC 2396. uri = URI::FTP.build(['user:password', 'ftp.example.com', nil, '/path/file.zip', 'i']) - assert(uri.to_s == - 'ftp://user:password@ftp.example.com/%2Fpath/file.zip;type=i') + assert_equal('ftp://user:password@ftp.example.com/%2Fpath/file.zip;type=i', + uri.to_s) end def test_select diff --git a/test/uri/test_generic.rb b/test/uri/test_generic.rb index 1d5fbc7..b893f7e 100644 --- a/test/uri/test_generic.rb +++ b/test/uri/test_generic.rb @@ -240,9 +240,9 @@ def test_merge u = URI.parse('http://foo/bar/baz') assert_equal(nil, u.merge!("")) assert_equal(nil, u.merge!(u)) - assert(nil != u.merge!(".")) + refute_nil(u.merge!(".")) assert_equal('http://foo/bar/', u.to_s) - assert(nil != u.merge!("../baz")) + refute_nil(u.merge!("../baz")) assert_equal('http://foo/baz', u.to_s) url = URI.parse('http://a/b//c') + 'd//e' @@ -356,7 +356,7 @@ def test_rfc3986_examples assert_equal('http://a/b/c/g', url.to_s) url = @base_url.route_to('http://a/b/c/g') assert_kind_of(URI::Generic, url) - assert('./g' != url.to_s) # ok + refute_equal('./g', url.to_s) # ok assert_equal('g', url.to_s) # http://a/b/c/d;p?q @@ -375,7 +375,7 @@ def test_rfc3986_examples assert_equal('http://a/g', url.to_s) url = @base_url.route_to('http://a/g') assert_kind_of(URI::Generic, url) - assert('/g' != url.to_s) # ok + refute_equal('/g', url.to_s) # ok assert_equal('../../g', url.to_s) # http://a/b/c/d;p?q @@ -466,7 +466,7 @@ def test_rfc3986_examples assert_equal('http://a/b/c/', url.to_s) url = @base_url.route_to('http://a/b/c/') assert_kind_of(URI::Generic, url) - assert('.' != url.to_s) # ok + refute_equal('.', url.to_s) # ok assert_equal('./', url.to_s) # http://a/b/c/d;p?q @@ -485,7 +485,7 @@ def test_rfc3986_examples assert_equal('http://a/b/', url.to_s) url = @base_url.route_to('http://a/b/') assert_kind_of(URI::Generic, url) - assert('..' != url.to_s) # ok + refute_equal('..', url.to_s) # ok assert_equal('../', url.to_s) # http://a/b/c/d;p?q @@ -513,7 +513,7 @@ def test_rfc3986_examples assert_equal('http://a/', url.to_s) url = @base_url.route_to('http://a/') assert_kind_of(URI::Generic, url) - assert('../..' != url.to_s) # ok + refute_equal('../..', url.to_s) # ok assert_equal('../../', url.to_s) # http://a/b/c/d;p?q @@ -604,7 +604,7 @@ def test_rfc3986_examples assert_equal('http://a/g', url.to_s) url = @base_url.route_to('http://a/g') assert_kind_of(URI::Generic, url) - assert('../../../g' != url.to_s) # ok? yes, it confuses you + refute_equal('../../../g', url.to_s) # ok? yes, it confuses you assert_equal('../../g', url.to_s) # and it is clearly # http://a/b/c/d;p?q @@ -614,7 +614,7 @@ def test_rfc3986_examples assert_equal('http://a/g', url.to_s) url = @base_url.route_to('http://a/g') assert_kind_of(URI::Generic, url) - assert('../../../../g' != url.to_s) # ok? yes, it confuses you + refute_equal('../../../../g', url.to_s) # ok? yes, it confuses you assert_equal('../../g', url.to_s) # and it is clearly # http://a/b/c/d;p?q @@ -624,7 +624,7 @@ def test_rfc3986_examples assert_equal('http://a/b/g', url.to_s) url = @base_url.route_to('http://a/b/g') assert_kind_of(URI::Generic, url) - assert('./../g' != url.to_s) # ok + refute_equal('./../g', url.to_s) # ok assert_equal('../g', url.to_s) # http://a/b/c/d;p?q @@ -634,7 +634,7 @@ def test_rfc3986_examples assert_equal('http://a/b/c/g/', url.to_s) url = @base_url.route_to('http://a/b/c/g/') assert_kind_of(URI::Generic, url) - assert('./g/.' != url.to_s) # ok + refute_equal('./g/.', url.to_s) # ok assert_equal('g/', url.to_s) # http://a/b/c/d;p?q @@ -644,7 +644,7 @@ def test_rfc3986_examples assert_equal('http://a/b/c/g/h', url.to_s) url = @base_url.route_to('http://a/b/c/g/h') assert_kind_of(URI::Generic, url) - assert('g/./h' != url.to_s) # ok + refute_equal('g/./h', url.to_s) # ok assert_equal('g/h', url.to_s) # http://a/b/c/d;p?q @@ -654,7 +654,7 @@ def test_rfc3986_examples assert_equal('http://a/b/c/h', url.to_s) url = @base_url.route_to('http://a/b/c/h') assert_kind_of(URI::Generic, url) - assert('g/../h' != url.to_s) # ok + refute_equal('g/../h', url.to_s) # ok assert_equal('h', url.to_s) # http://a/b/c/d;p?q @@ -664,7 +664,7 @@ def test_rfc3986_examples assert_equal('http://a/b/c/g;x=1/y', url.to_s) url = @base_url.route_to('http://a/b/c/g;x=1/y') assert_kind_of(URI::Generic, url) - assert('g;x=1/./y' != url.to_s) # ok + refute_equal('g;x=1/./y', url.to_s) # ok assert_equal('g;x=1/y', url.to_s) # http://a/b/c/d;p?q @@ -674,7 +674,7 @@ def test_rfc3986_examples assert_equal('http://a/b/c/y', url.to_s) url = @base_url.route_to('http://a/b/c/y') assert_kind_of(URI::Generic, url) - assert('g;x=1/../y' != url.to_s) # ok + refute_equal('g;x=1/../y', url.to_s) # ok assert_equal('y', url.to_s) # http://a/b/c/d;p?q @@ -822,18 +822,18 @@ def test_hierarchical hierarchical = URI.parse('http://a.b.c/example') opaque = URI.parse('mailto:mduerst@ifi.unizh.ch') - assert hierarchical.hierarchical? - refute opaque.hierarchical? + assert_predicate hierarchical, :hierarchical? + refute_predicate opaque, :hierarchical? end def test_absolute abs_uri = URI.parse('http://a.b.c/') not_abs = URI.parse('a.b.c') - refute not_abs.absolute? + refute_predicate not_abs, :absolute? - assert abs_uri.absolute - assert abs_uri.absolute? + assert_predicate abs_uri, :absolute + assert_predicate abs_uri, :absolute? end def test_ipv6 diff --git a/test/uri/test_http.rb b/test/uri/test_http.rb index e937b1a..dc076ce 100644 --- a/test/uri/test_http.rb +++ b/test/uri/test_http.rb @@ -33,19 +33,19 @@ def test_normalize host = 'aBcD' u1 = URI.parse('http://' + host + '/eFg?HiJ') u2 = URI.parse('http://' + host.downcase + '/eFg?HiJ') - assert(u1.normalize.host == 'abcd') - assert(u1.normalize.path == u1.path) - assert(u1.normalize == u2.normalize) - assert(!u1.normalize.host.equal?(u1.host)) - assert( u2.normalize.host.equal?(u2.host)) + assert_equal('abcd', u1.normalize.host) + assert_equal(u1.path, u1.normalize.path) + assert_equal(u2.normalize, u1.normalize) + refute_same(u1.host, u1.normalize.host) + assert_same(u2.host, u2.normalize.host) assert_equal('http://abc/', URI.parse('http://abc').normalize.to_s) end def test_equal - assert(URI.parse('http://abc') == URI.parse('http://ABC')) - assert(URI.parse('http://abc/def') == URI.parse('http://ABC/def')) - assert(URI.parse('http://abc/def') != URI.parse('http://ABC/DEF')) + assert_equal(URI.parse('http://ABC'), URI.parse('http://abc')) + assert_equal(URI.parse('http://ABC/def'), URI.parse('http://abc/def')) + refute_equal(URI.parse('http://ABC/DEF'), URI.parse('http://abc/def')) end def test_request_uri diff --git a/test/uri/test_parser.rb b/test/uri/test_parser.rb index f455a5c..04c2cd3 100644 --- a/test/uri/test_parser.rb +++ b/test/uri/test_parser.rb @@ -20,17 +20,17 @@ def test_compare u2 = p.parse(url) u3 = p.parse(url) - assert(u0 == u1) - assert(u0.eql?(u1)) - assert(!u0.equal?(u1)) + assert_equal(u1, u0) + assert_send([u0, :eql?, u1]) + refute_same(u1, u0) - assert(u1 == u2) - assert(!u1.eql?(u2)) - assert(!u1.equal?(u2)) + assert_equal(u2, u1) + assert_not_send([u1, :eql?, u2]) + refute_same(u1, u2) - assert(u2 == u3) - assert(u2.eql?(u3)) - assert(!u2.equal?(u3)) + assert_equal(u3, u2) + assert_send([u2, :eql?, u3]) + refute_same(u3, u2) end def test_parse_rfc2396_parser diff --git a/test/uri/test_ws.rb b/test/uri/test_ws.rb index f3918f6..d63ebd4 100644 --- a/test/uri/test_ws.rb +++ b/test/uri/test_ws.rb @@ -31,19 +31,19 @@ def test_normalize host = 'aBcD' u1 = URI.parse('ws://' + host + '/eFg?HiJ') u2 = URI.parse('ws://' + host.downcase + '/eFg?HiJ') - assert(u1.normalize.host == 'abcd') - assert(u1.normalize.path == u1.path) - assert(u1.normalize == u2.normalize) - assert(!u1.normalize.host.equal?(u1.host)) - assert( u2.normalize.host.equal?(u2.host)) + assert_equal('abcd', u1.normalize.host) + assert_equal(u1.path, u1.normalize.path) + assert_equal(u2.normalize, u1.normalize) + refute_same(u1.host, u1.normalize.host) + assert_same(u2.host, u2.normalize.host) assert_equal('ws://abc/', URI.parse('ws://abc').normalize.to_s) end def test_equal - assert(URI.parse('ws://abc') == URI.parse('ws://ABC')) - assert(URI.parse('ws://abc/def') == URI.parse('ws://ABC/def')) - assert(URI.parse('ws://abc/def') != URI.parse('ws://ABC/DEF')) + assert_equal(URI.parse('ws://ABC'), URI.parse('ws://abc')) + assert_equal(URI.parse('ws://ABC/def'), URI.parse('ws://abc/def')) + refute_equal(URI.parse('ws://ABC/DEF'), URI.parse('ws://abc/def')) end def test_request_uri diff --git a/test/uri/test_wss.rb b/test/uri/test_wss.rb index 13a2583..cbef327 100644 --- a/test/uri/test_wss.rb +++ b/test/uri/test_wss.rb @@ -31,19 +31,19 @@ def test_normalize host = 'aBcD' u1 = URI.parse('wss://' + host + '/eFg?HiJ') u2 = URI.parse('wss://' + host.downcase + '/eFg?HiJ') - assert(u1.normalize.host == 'abcd') - assert(u1.normalize.path == u1.path) - assert(u1.normalize == u2.normalize) - assert(!u1.normalize.host.equal?(u1.host)) - assert( u2.normalize.host.equal?(u2.host)) + assert_equal('abcd', u1.normalize.host) + assert_equal(u1.path, u1.normalize.path) + assert_equal(u2.normalize, u1.normalize) + refute_same(u1.host, u1.normalize.host) + assert_same(u2.host, u2.normalize.host) assert_equal('wss://abc/', URI.parse('wss://abc').normalize.to_s) end def test_equal - assert(URI.parse('wss://abc') == URI.parse('wss://ABC')) - assert(URI.parse('wss://abc/def') == URI.parse('wss://ABC/def')) - assert(URI.parse('wss://abc/def') != URI.parse('wss://ABC/DEF')) + assert_equal(URI.parse('wss://ABC'), URI.parse('wss://abc')) + assert_equal(URI.parse('wss://ABC/def'), URI.parse('wss://abc/def')) + refute_equal(URI.parse('wss://ABC/DEF'), URI.parse('wss://abc/def')) end def test_request_uri From 6f44d3d40e5342041315f25b153ba8e4d5e0e745 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sat, 12 Jul 2025 12:02:37 +0900 Subject: [PATCH 79/92] Fix the message for unexpected argument Use just `self` instead of `self.class`, in `URI::Generic.build`. Since this is a class method, `self.class` is always `Class` even in inherited sub classes, and does not have `#component` method. --- lib/uri/generic.rb | 4 ++-- test/uri/test_generic.rb | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/uri/generic.rb b/lib/uri/generic.rb index 07f329e..8cd280d 100644 --- a/lib/uri/generic.rb +++ b/lib/uri/generic.rb @@ -126,9 +126,9 @@ def self.build(args) end end else - component = self.class.component rescue ::URI::Generic::COMPONENT + component = self.component rescue ::URI::Generic::COMPONENT raise ArgumentError, - "expected Array of or Hash of components of #{self.class} (#{component.join(', ')})" + "expected Array of or Hash of components of #{self} (#{component.join(', ')})" end tmp << nil diff --git a/test/uri/test_generic.rb b/test/uri/test_generic.rb index b893f7e..0d29dd4 100644 --- a/test/uri/test_generic.rb +++ b/test/uri/test_generic.rb @@ -868,6 +868,19 @@ def test_build assert_equal("http://[::1]/bar/baz", u.to_s) assert_equal("[::1]", u.host) assert_equal("::1", u.hostname) + + assert_raise_with_message(ArgumentError, /URI::Generic/) { + URI::Generic.build(nil) + } + + c = Class.new(URI::Generic) do + def self.component; raise; end + end + expected = /\(#{URI::Generic::COMPONENT.join(', ')}\)/ + message = "fallback to URI::Generic::COMPONENT if component raised" + assert_raise_with_message(ArgumentError, expected, message) { + c.build(nil) + } end def test_build2 From 0c2b6468fa4f57288b1e4a462986985b6c942b22 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 8 Jul 2025 19:35:06 +0900 Subject: [PATCH 80/92] Make URI::regexp schemes case sensitive (#38) --- 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 75a2d2d..c6096c4 100644 --- a/lib/uri/rfc2396_parser.rb +++ b/lib/uri/rfc2396_parser.rb @@ -263,7 +263,7 @@ def make_regexp(schemes = nil) 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 04c2cd3..c14824f 100644 --- a/test/uri/test_parser.rb +++ b/test/uri/test_parser.rb @@ -113,4 +113,12 @@ def test_rfc3986_port_check 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 From b1b5f9a476ecd16d82c4c9cde59b86d2efc582a2 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sat, 12 Jul 2025 15:53:33 +0900 Subject: [PATCH 81/92] More tests for `check_to` --- test/uri/test_mailto.rb | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/test/uri/test_mailto.rb b/test/uri/test_mailto.rb index e7c04ef..31adae2 100644 --- a/test/uri/test_mailto.rb +++ b/test/uri/test_mailto.rb @@ -165,6 +165,45 @@ def test_check_to assert_raise(URI::InvalidComponentError) do u.to = 'n.@invalid.email' end + + # Invalid host emails + assert_raise(URI::InvalidComponentError) do + u.to = 'a@.invalid.email' + end + + assert_raise(URI::InvalidComponentError) do + u.to = 'a@invalid.email.' + end + + assert_raise(URI::InvalidComponentError) do + u.to = 'a@invalid..email' + end + + assert_raise(URI::InvalidComponentError) do + u.to = 'a@-invalid.email' + end + + assert_raise(URI::InvalidComponentError) do + u.to = 'a@invalid-.email' + end + + assert_raise(URI::InvalidComponentError) do + u.to = 'a@invalid.-email' + end + + assert_raise(URI::InvalidComponentError) do + u.to = 'a@invalid.email-' + end + + u.to = 'a@'+'invalid'.ljust(63, 'd')+'.email' + assert_raise(URI::InvalidComponentError) do + u.to = 'a@'+'invalid'.ljust(64, 'd')+'.email' + end + + u.to = 'a@invalid.'+'email'.rjust(63, 'e') + assert_raise(URI::InvalidComponentError) do + u.to = 'a@invalid.'+'email'.rjust(64, 'e') + end end def test_to_s From 32335923bf4dd20d11480b8d45cdd97800e964cb Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sat, 12 Jul 2025 15:54:38 +0900 Subject: [PATCH 82/92] Prohibit successive dots in email --- lib/uri/mailto.rb | 2 +- test/uri/test_mailto.rb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/uri/mailto.rb b/lib/uri/mailto.rb index a15d2f0..bd63aa0 100644 --- a/lib/uri/mailto.rb +++ b/lib/uri/mailto.rb @@ -52,7 +52,7 @@ class MailTo < Generic HEADER_REGEXP = /\A(?(?:%\h\h|[!$'-.0-;@-Z_a-z~])*=(?:%\h\h|[!$'-.0-;@-Z_a-z~])*)(?:&\g)*\z/ # practical regexp for email address # https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address - EMAIL_REGEXP = /\A(?!\.)[a-zA-Z0-9.!\#$%&'*+\/=?^_`{|}~-]+(? Date: Sat, 12 Jul 2025 19:31:31 +0900 Subject: [PATCH 83/92] Improve performance of `URI::MailTo::EMAIL_REGEXP` Fix the performance regression at #172 for valid emails. ``` yml prelude: | require 'uri/mailto' n = 1000 re = URI::MailTo::EMAIL_REGEXP benchmark: n.t..t.: re.match?("n.t..t.@docomo.ne.jp") example: re.match?("example@example.info") ``` | |released| 788274b| c5974f0| this| |:--------|-------:|-------:|-------:|-------:| |n.t..t. | 3.795M| 4.864M| 4.993M| 8.739M| | | -| 1.28x| 1.32x| 2.30x| |example | 3.911M| 3.740M| 2.838M| 3.880M| | | 1.38x| 1.32x| -| 1.37x| --- lib/uri/mailto.rb | 6 +++++- test/uri/test_mailto.rb | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/uri/mailto.rb b/lib/uri/mailto.rb index bd63aa0..f747b79 100644 --- a/lib/uri/mailto.rb +++ b/lib/uri/mailto.rb @@ -52,7 +52,11 @@ class MailTo < Generic HEADER_REGEXP = /\A(?(?:%\h\h|[!$'-.0-;@-Z_a-z~])*=(?:%\h\h|[!$'-.0-;@-Z_a-z~])*)(?:&\g)*\z/ # practical regexp for email address # https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address - EMAIL_REGEXP = /\A(?!\.)(?!.*\.{2})[a-zA-Z0-9.!\#$%&'*+\/=?^_`{|}~-]+(?(n) {'a@invalid' + longlabel*(n*rate) + endlabel} + assert_linear_performance(1..10, pre: pre) do |to| + re =~ to or flunk + end + endlabel = '.' + 'email'.rjust(64, 'd') + assert_linear_performance(1..10, pre: pre) do |to| + re =~ to and flunk + end + end + def test_to_s u = URI::MailTo.build([nil, 'subject=Ruby']) From be35e0b4d8668352309da80d9cbc6cbb3d6e81f8 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sat, 12 Jul 2025 20:05:48 +0900 Subject: [PATCH 84/92] Test in exponential scale with rehearsal --- test/uri/test_mailto.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/test/uri/test_mailto.rb b/test/uri/test_mailto.rb index 66f3edd..e5bed5b 100644 --- a/test/uri/test_mailto.rb +++ b/test/uri/test_mailto.rb @@ -213,15 +213,16 @@ def test_check_to def test_email_regexp re = URI::MailTo::EMAIL_REGEXP - rate = 1000 longlabel = '.' + 'invalid'.ljust(63, 'd') endlabel = '' - pre = ->(n) {'a@invalid' + longlabel*(n*rate) + endlabel} - assert_linear_performance(1..10, pre: pre) do |to| + seq = (1..5).map {|i| 5**i} + rehearsal = 100 + pre = ->(n) {'a@invalid' + longlabel*(n) + endlabel} + assert_linear_performance(seq, rehearsal: rehearsal, pre: pre) do |to| re =~ to or flunk end endlabel = '.' + 'email'.rjust(64, 'd') - assert_linear_performance(1..10, pre: pre) do |to| + assert_linear_performance(seq, rehearsal: rehearsal, pre: pre) do |to| re =~ to and flunk end end From fa49e5b8ae6078cad1f276c4edb33e4f23929bf4 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 13 Jul 2025 13:18:15 +0900 Subject: [PATCH 85/92] Repeat matching to reduce deviations --- test/uri/test_mailto.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/test/uri/test_mailto.rb b/test/uri/test_mailto.rb index e5bed5b..59bb5de 100644 --- a/test/uri/test_mailto.rb +++ b/test/uri/test_mailto.rb @@ -213,17 +213,18 @@ def test_check_to def test_email_regexp re = URI::MailTo::EMAIL_REGEXP + repeat = 10 longlabel = '.' + 'invalid'.ljust(63, 'd') endlabel = '' - seq = (1..5).map {|i| 5**i} - rehearsal = 100 + seq = (1..3).map {|i| 10**i} + rehearsal = 10 pre = ->(n) {'a@invalid' + longlabel*(n) + endlabel} assert_linear_performance(seq, rehearsal: rehearsal, pre: pre) do |to| - re =~ to or flunk + repeat.times {re =~ to or flunk} end endlabel = '.' + 'email'.rjust(64, 'd') assert_linear_performance(seq, rehearsal: rehearsal, pre: pre) do |to| - re =~ to and flunk + repeat.times {re =~ to and flunk} end end From 452d74390c9b5ebcbdb9fc9a8db0f2febb659ef6 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Mon, 14 Jul 2025 13:14:53 +0900 Subject: [PATCH 86/92] [DOC] Fix references These are instance methods, not class methods. And `URI::Parser` was moved to URI::RFC2396_Parser at [r46491] [r46491]: ruby/ruby@bb83f32dc3e0424d25fa4e55d8ff32b061320e41 --- lib/uri/rfc2396_parser.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/uri/rfc2396_parser.rb b/lib/uri/rfc2396_parser.rb index c6096c4..8fdbf4b 100644 --- a/lib/uri/rfc2396_parser.rb +++ b/lib/uri/rfc2396_parser.rb @@ -108,12 +108,12 @@ def initialize(opts = {}) # The Hash of patterns. # - # See also URI::Parser.initialize_pattern. + # See also #initialize_pattern. attr_reader :pattern # The Hash of Regexp. # - # See also URI::Parser.initialize_regexp. + # See also #initialize_regexp. attr_reader :regexp # Returns a split URI against +regexp[:ABS_URI]+. @@ -244,7 +244,7 @@ def join(*uris) # If no +block+ given, then returns the result, # else it calls +block+ for each element in result. # - # See also URI::Parser.make_regexp. + # See also #make_regexp. # def extract(str, schemes = nil) if block_given? From 372fbb455d6c21370945d1e77472984d2be2bdae Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Mon, 14 Jul 2025 13:23:54 +0900 Subject: [PATCH 87/92] [DOC] Document private visibility too For the references to URI::RFC2396_Parser private methods. --- .rdoc_options | 1 + lib/uri/common.rb | 6 ++++++ lib/uri/rfc2396_parser.rb | 2 ++ 3 files changed, 9 insertions(+) diff --git a/.rdoc_options b/.rdoc_options index b1f9cda..cd5e496 100644 --- a/.rdoc_options +++ b/.rdoc_options @@ -2,3 +2,4 @@ main_page: README.md op_dir: _site warn_missing_rdoc_ref: true title: URI Documentation +visibility: :private diff --git a/lib/uri/common.rb b/lib/uri/common.rb index 411a7e3..baa0fd2 100644 --- a/lib/uri/common.rb +++ b/lib/uri/common.rb @@ -159,9 +159,11 @@ def self.scheme_list Schemes.list end + # :stopdoc: INITIAL_SCHEMES = scheme_list private_constant :INITIAL_SCHEMES Ractor.make_shareable(INITIAL_SCHEMES) if defined?(Ractor) + # :startdoc: # Returns a new object constructed from the given +scheme+, +arguments+, # and +default+: @@ -437,6 +439,8 @@ def self.decode_uri_component(str, enc=Encoding::UTF_8) _decode_uri_component(/%\h\h/, str, enc) end + # Returns a string derived from the given string +str+ with + # URI-encoded characters matching +regexp+ according to +table+. def self._encode_uri_component(regexp, table, str, enc) str = str.to_s.dup if str.encoding != Encoding::ASCII_8BIT @@ -451,6 +455,8 @@ def self._encode_uri_component(regexp, table, str, enc) end private_class_method :_encode_uri_component + # Returns a string decoding characters matching +regexp+ from the + # given \URL-encoded string +str+. def self._decode_uri_component(regexp, str, enc) raise ArgumentError, "invalid %-encoding (#{str})" if /%(?!\h\h)/.match?(str) str.b.gsub(regexp, TBLDECWWWCOMP_).force_encoding(enc) diff --git a/lib/uri/rfc2396_parser.rb b/lib/uri/rfc2396_parser.rb index 8fdbf4b..f0d544e 100644 --- a/lib/uri/rfc2396_parser.rb +++ b/lib/uri/rfc2396_parser.rb @@ -524,6 +524,8 @@ def initialize_regexp(pattern) ret end + # Returns +uri+ as-is if it is URI, or convert it to URI if it is + # a String. def convert_to_uri(uri) if uri.is_a?(URI::Generic) uri From d2a79c63430a8374b9d9ee1486027caadce35418 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Mon, 14 Jul 2025 13:54:07 +0900 Subject: [PATCH 88/92] [DOC] Update old use of `URI::Parser` --- lib/uri/generic.rb | 18 +++++++++--------- lib/uri/rfc2396_parser.rb | 7 +++---- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/lib/uri/generic.rb b/lib/uri/generic.rb index 8cd280d..d811c5b 100644 --- a/lib/uri/generic.rb +++ b/lib/uri/generic.rb @@ -284,7 +284,7 @@ def registry # :nodoc: # Returns the parser to be used. # - # Unless a URI::Parser is defined, DEFAULT_PARSER is used. + # Unless the +parser+ is defined, DEFAULT_PARSER is used. # def parser if !defined?(@parser) || !@parser @@ -315,7 +315,7 @@ def component end # - # Checks the scheme +v+ component against the URI::Parser Regexp for :SCHEME. + # Checks the scheme +v+ component against the +parser+ Regexp for :SCHEME. # def check_scheme(v) if v && parser.regexp[:SCHEME] !~ v @@ -385,7 +385,7 @@ def check_userinfo(user, password = nil) # # Checks the user +v+ component for RFC2396 compliance - # and against the URI::Parser Regexp for :USERINFO. + # and against the +parser+ Regexp for :USERINFO. # # Can not have a registry or opaque component defined, # with a user component defined. @@ -409,7 +409,7 @@ def check_user(v) # # Checks the password +v+ component for RFC2396 compliance - # and against the URI::Parser Regexp for :USERINFO. + # and against the +parser+ Regexp for :USERINFO. # # Can not have a registry or opaque component defined, # with a user component defined. @@ -586,7 +586,7 @@ def decoded_password # # Checks the host +v+ component for RFC2396 compliance - # and against the URI::Parser Regexp for :HOST. + # and against the +parser+ Regexp for :HOST. # # Can not have a registry or opaque component defined, # with a host component defined. @@ -675,7 +675,7 @@ def hostname=(v) # # Checks the port +v+ component for RFC2396 compliance - # and against the URI::Parser Regexp for :PORT. + # and against the +parser+ Regexp for :PORT. # # Can not have a registry or opaque component defined, # with a port component defined. @@ -748,7 +748,7 @@ def registry=(v) # :nodoc: # # Checks the path +v+ component for RFC2396 compliance - # and against the URI::Parser Regexp + # and against the +parser+ Regexp # for :ABS_PATH and :REL_PATH. # # Can not have a opaque component defined, @@ -853,7 +853,7 @@ def query=(v) # # Checks the opaque +v+ component for RFC2396 compliance and - # against the URI::Parser Regexp for :OPAQUE. + # against the +parser+ Regexp for :OPAQUE. # # Can not have a host, port, user, or path component defined, # with an opaque component defined. @@ -905,7 +905,7 @@ def opaque=(v) end # - # Checks the fragment +v+ component against the URI::Parser Regexp for :FRAGMENT. + # Checks the fragment +v+ component against the +parser+ Regexp for :FRAGMENT. # # # == Args diff --git a/lib/uri/rfc2396_parser.rb b/lib/uri/rfc2396_parser.rb index f0d544e..cefd126 100644 --- a/lib/uri/rfc2396_parser.rb +++ b/lib/uri/rfc2396_parser.rb @@ -67,7 +67,7 @@ class RFC2396_Parser # # == Synopsis # - # URI::Parser.new([opts]) + # URI::RFC2396_Parser.new([opts]) # # == Args # @@ -86,7 +86,7 @@ class RFC2396_Parser # # == Examples # - # p = URI::Parser.new(:ESCAPED => "(?:%[a-fA-F0-9]{2}|%u[a-fA-F0-9]{4})") + # p = URI::RFC2396_Parser.new(:ESCAPED => "(?:%[a-fA-F0-9]{2}|%u[a-fA-F0-9]{4})") # u = p.parse("http://example.jp/%uABCD") #=> # # URI.parse(u.to_s) #=> raises URI::InvalidURIError # @@ -202,8 +202,7 @@ def split(uri) # # == Usage # - # p = URI::Parser.new - # p.parse("ldap://ldap.example.com/dc=example?user=john") + # URI::RFC2396_PARSER.parse("ldap://ldap.example.com/dc=example?user=john") # #=> # # def parse(uri) From 7c13b16a35a61ea53d869dacec164a1c6ffe6f69 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Jul 2025 00:45:22 +0000 Subject: [PATCH 89/92] Bump step-security/harden-runner from 2.12.2 to 2.13.0 Bumps [step-security/harden-runner](https://github.com/step-security/harden-runner) from 2.12.2 to 2.13.0. - [Release notes](https://github.com/step-security/harden-runner/releases) - [Commits](https://github.com/step-security/harden-runner/compare/6c439dc8bdf85cadbbce9ed30d1c7b959517bc49...ec9f2d5744a09debf3a187a3f4f675c53b671911) --- updated-dependencies: - dependency-name: step-security/harden-runner dependency-version: 2.13.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/push_gem.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push_gem.yml b/.github/workflows/push_gem.yml index df1e741..d4f354e 100644 --- a/.github/workflows/push_gem.yml +++ b/.github/workflows/push_gem.yml @@ -23,7 +23,7 @@ jobs: steps: - name: Harden Runner - uses: step-security/harden-runner@6c439dc8bdf85cadbbce9ed30d1c7b959517bc49 # v2.12.2 + uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0 with: egress-policy: audit From 49fc1e7040130838812ab50422292b98e340e221 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Aug 2025 00:49:01 +0000 Subject: [PATCH 90/92] Bump actions/checkout from 4 to 5 Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 5. - [Release notes](https://github.com/actions/checkout/releases) - [Commits](https://github.com/actions/checkout/compare/v4...v5) --- updated-dependencies: - dependency-name: actions/checkout dependency-version: '5' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/gh-pages.yml | 2 +- .github/workflows/push_gem.yml | 2 +- .github/workflows/test.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index e7ee429..1989641 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -19,7 +19,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Setup Ruby uses: ruby/setup-ruby@32110d4e311bd8996b2a82bf2a43b714ccc91777 # v1.221.0 with: diff --git a/.github/workflows/push_gem.yml b/.github/workflows/push_gem.yml index d4f354e..b7d2984 100644 --- a/.github/workflows/push_gem.yml +++ b/.github/workflows/push_gem.yml @@ -27,7 +27,7 @@ jobs: with: egress-policy: audit - - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + - uses: actions/checkout@ff7abcd0c3c05ccf6adc123a8cd1fd4fb30fb493 # v4.1.4 - name: Set up Ruby uses: ruby/setup-ruby@a6e6f86333f0a2523ece813039b8b4be04560854 # v1.190.0 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ee9b2a5..ba860e8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,7 +20,7 @@ jobs: os: macos-latest runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Set up Ruby uses: ruby/setup-ruby@v1 with: From 0b8f44009509061440c1be2f537fdaf619bed87b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Aug 2025 00:26:44 +0000 Subject: [PATCH 91/92] Bump actions/upload-pages-artifact from 3 to 4 Bumps [actions/upload-pages-artifact](https://github.com/actions/upload-pages-artifact) from 3 to 4. - [Release notes](https://github.com/actions/upload-pages-artifact/releases) - [Commits](https://github.com/actions/upload-pages-artifact/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/upload-pages-artifact dependency-version: '4' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/gh-pages.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index 1989641..585eb8a 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -32,7 +32,7 @@ jobs: # Outputs to the './_site' directory by default run: rake rdoc - name: Upload artifact - uses: actions/upload-pages-artifact@v3 + uses: actions/upload-pages-artifact@v4 deploy: environment: From 5bf1ab9de6ca323e4ba07e3a2f619c5d970299b6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Sep 2025 00:02:02 +0000 Subject: [PATCH 92/92] Bump step-security/harden-runner from 2.13.0 to 2.13.1 Bumps [step-security/harden-runner](https://github.com/step-security/harden-runner) from 2.13.0 to 2.13.1. - [Release notes](https://github.com/step-security/harden-runner/releases) - [Commits](https://github.com/step-security/harden-runner/compare/ec9f2d5744a09debf3a187a3f4f675c53b671911...f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a) --- updated-dependencies: - dependency-name: step-security/harden-runner dependency-version: 2.13.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/push_gem.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push_gem.yml b/.github/workflows/push_gem.yml index b7d2984..c6b1e47 100644 --- a/.github/workflows/push_gem.yml +++ b/.github/workflows/push_gem.yml @@ -23,7 +23,7 @@ jobs: steps: - name: Harden Runner - uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0 + uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1 with: egress-policy: audit