aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/inflector/transliterate.rb
diff options
context:
space:
mode:
authorEileen M. Uchitelle <eileencodes@users.noreply.github.com>2019-07-31 13:04:58 -0400
committerGitHub <noreply@github.com>2019-07-31 13:04:58 -0400
commitf66bfdb2841bedda0f92f573fb2e5e894c35c7ed (patch)
treed5c993de8d8acbf575e4c9219fd9f8df2d861f37 /activesupport/lib/active_support/inflector/transliterate.rb
parent4b65173479830f257ce2299c24eda2ffc6c9db5e (diff)
parentfc6ec7bfc7d1cc13380ac91eac3caeaa5e37df02 (diff)
downloadrails-f66bfdb2841bedda0f92f573fb2e5e894c35c7ed.tar.gz
rails-f66bfdb2841bedda0f92f573fb2e5e894c35c7ed.tar.bz2
rails-f66bfdb2841bedda0f92f573fb2e5e894c35c7ed.zip
Merge pull request #36825 from cpruitt/transliterate-frozen-us-ascii-strings
Prevent error on transliterate with frozen strings
Diffstat (limited to 'activesupport/lib/active_support/inflector/transliterate.rb')
-rw-r--r--activesupport/lib/active_support/inflector/transliterate.rb1
1 files changed, 1 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/inflector/transliterate.rb b/activesupport/lib/active_support/inflector/transliterate.rb
index 3ba2d93ed8..1899a1212d 100644
--- a/activesupport/lib/active_support/inflector/transliterate.rb
+++ b/activesupport/lib/active_support/inflector/transliterate.rb
@@ -60,6 +60,7 @@ module ActiveSupport
# Transliteration is restricted to UTF-8, US-ASCII and GB18030 strings
# Other encodings will raise an ArgumentError.
def transliterate(string, replacement = "?", locale: nil)
+ string = string.dup if string.frozen?
raise ArgumentError, "Can only transliterate strings. Received #{string.class.name}" unless string.is_a?(String)
allowed_encodings = [Encoding::UTF_8, Encoding::US_ASCII, Encoding::GB18030]