Skip to content

Commit

Permalink
Explicitly freeze concatenated-String constants to unbreak on non-m…
Browse files Browse the repository at this point in the history
…ain `Ractor`s.
  • Loading branch information
okeeblow committed Jan 15, 2022
1 parent f3fb80c commit 37d2285
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions lib/addressable/uri.rb
Expand Up @@ -38,20 +38,26 @@ class InvalidURIError < StandardError
##
# Container for the character classes specified in
# <a href="http://www.ietf.org/rfc/rfc3986.txt">RFC 3986</a>.
#
# Note: Concatenated and interpolated `String`s are not affected by the
# `frozen_string_literal` directive and must be frozen explicitly.
#
# Interpolated `String`s *were* frozen this way before Ruby 3.0:
# https://bugs.ruby-lang.org/issues/17104
module CharacterClasses
ALPHA = "a-zA-Z"
DIGIT = "0-9"
GEN_DELIMS = "\\:\\/\\?\\#\\[\\]\\@"
SUB_DELIMS = "\\!\\$\\&\\'\\(\\)\\*\\+\\,\\;\\="
RESERVED = GEN_DELIMS + SUB_DELIMS
UNRESERVED = ALPHA + DIGIT + "\\-\\.\\_\\~"
PCHAR = UNRESERVED + SUB_DELIMS + "\\:\\@"
SCHEME = ALPHA + DIGIT + "\\-\\+\\."
HOST = UNRESERVED + SUB_DELIMS + "\\[\\:\\]"
AUTHORITY = PCHAR + "\\[\\:\\]"
PATH = PCHAR + "\\/"
QUERY = PCHAR + "\\/\\?"
FRAGMENT = PCHAR + "\\/\\?"
RESERVED = %q{GEN_DELIMS SUB_DELIMS}.freeze
UNRESERVED = %q{ALPHA DIGIT "\\-\\.\\_\\~"}.freeze
PCHAR = %q{UNRESERVED SUB_DELIMS "\\:\\@"}.freeze
SCHEME = %q{ALPHA DIGIT "\\-\\+\\."}.freeze
HOST = %q{UNRESERVED SUB_DELIMS "\\[\\:\\]"}.freeze
AUTHORITY = %q{PCHAR "\\[\\:\\]"}.freeze
PATH = %q{PCHAR "\\/"}.freeze
QUERY = %q{PCHAR "\\/\\?"}.freeze
FRAGMENT = %q{PCHAR "\\/\\?"}.freeze
end

module NormalizeCharacterClasses
Expand Down

0 comments on commit 37d2285

Please sign in to comment.