Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7ecf751

Browse filesBrowse files
authored
Merge pull request #449 from okeeblow/freeze_concatenated_strings
Explicitly freeze concatenated-`String` constants to unbreak on non-main `Ractor`s.
2 parents 068f673 + 41f12dd commit 7ecf751
Copy full SHA for 7ecf751

File tree

Expand file treeCollapse file tree

2 files changed

+25
-9
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+25
-9
lines changed
Open diff view settings
Collapse file

‎lib/addressable/uri.rb‎

Copy file name to clipboardExpand all lines: lib/addressable/uri.rb
+15-9Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,26 @@ class InvalidURIError < StandardError
3737
##
3838
# Container for the character classes specified in
3939
# <a href="http://www.ietf.org/rfc/rfc3986.txt">RFC 3986</a>.
40+
#
41+
# Note: Concatenated and interpolated `String`s are not affected by the
42+
# `frozen_string_literal` directive and must be frozen explicitly.
43+
#
44+
# Interpolated `String`s *were* frozen this way before Ruby 3.0:
45+
# https://bugs.ruby-lang.org/issues/17104
4046
module CharacterClasses
4147
ALPHA = "a-zA-Z"
4248
DIGIT = "0-9"
4349
GEN_DELIMS = "\\:\\/\\?\\#\\[\\]\\@"
4450
SUB_DELIMS = "\\!\\$\\&\\'\\(\\)\\*\\+\\,\\;\\="
45-
RESERVED = GEN_DELIMS + SUB_DELIMS
46-
UNRESERVED = ALPHA + DIGIT + "\\-\\.\\_\\~"
47-
PCHAR = UNRESERVED + SUB_DELIMS + "\\:\\@"
48-
SCHEME = ALPHA + DIGIT + "\\-\\+\\."
49-
HOST = UNRESERVED + SUB_DELIMS + "\\[\\:\\]"
50-
AUTHORITY = PCHAR + "\\[\\]"
51-
PATH = PCHAR + "\\/"
52-
QUERY = PCHAR + "\\/\\?"
53-
FRAGMENT = PCHAR + "\\/\\?"
51+
RESERVED = (GEN_DELIMS + SUB_DELIMS).freeze
52+
UNRESERVED = (ALPHA + DIGIT + "\\-\\.\\_\\~").freeze
53+
PCHAR = (UNRESERVED + SUB_DELIMS + "\\:\\@").freeze
54+
SCHEME = (ALPHA + DIGIT + "\\-\\+\\.").freeze
55+
HOST = (UNRESERVED + SUB_DELIMS + "\\[\\:\\]").freeze
56+
AUTHORITY = (PCHAR + "\\[\\:\\]").freeze
57+
PATH = (PCHAR + "\\/").freeze
58+
QUERY = (PCHAR + "\\/\\?").freeze
59+
FRAGMENT = (PCHAR + "\\/\\?").freeze
5460
end
5561

5662
module NormalizeCharacterClasses
Collapse file

‎spec/addressable/uri_spec.rb‎

Copy file name to clipboardExpand all lines: spec/addressable/uri_spec.rb
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6667,3 +6667,13 @@ def to_str
66676667
expect(@uri.class).to eq(@uri.join('path').class)
66686668
end
66696669
end
6670+
6671+
describe Addressable::URI, "when initialized in a non-main `Ractor`" do
6672+
it "should have the same value as if used in the main `Ractor`" do
6673+
pending("Ruby 3.0+ for `Ractor` support") unless defined?(Ractor)
6674+
main = Addressable::URI.parse("http://example.com")
6675+
expect(
6676+
Ractor.new { Addressable::URI.parse("http://example.com") }.take
6677+
).to eq(main)
6678+
end
6679+
end

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.