From 63edb3e8c49d9882b32705ff43f506903e8af5dc Mon Sep 17 00:00:00 2001 From: benjamin wil Date: Sun, 20 Feb 2022 15:27:19 -0800 Subject: [PATCH] Do not attempt to modify frozen strings Using `#gsub!` here now results in an error. I am not entirely sure why this hasn't happened before, but the error is straightforward: FrozenError: can't modify frozen String: "Author %{author} is from %{location}" /home/runner/work/gollum/gollum/lib/gollum/views/helpers/locale_helpers.rb:45:in `gsub!' /home/runner/work/gollum/gollum/lib/gollum/views/helpers/locale_helpers.rb:45:in `fill_argument_content' /home/runner/work/gollum/gollum/lib/gollum/views/helpers/locale_helpers.rb:37:in `block in autofill' /home/runner/work/gollum/gollum/lib/gollum/views/helpers/locale_helpers.rb:33:in `each' /home/runner/work/gollum/gollum/lib/gollum/views/helpers/locale_helpers.rb:33:in `map' /home/runner/work/gollum/gollum/lib/gollum/views/helpers/locale_helpers.rb:33:in `autofill' /home/runner/work/gollum/gollum/lib/gollum/views/helpers/locale_helpers.rb:35:in `block in autofill' /home/runner/work/gollum/gollum/lib/gollum/views/helpers/locale_helpers.rb:33:in `each' /home/runner/work/gollum/gollum/lib/gollum/views/helpers/locale_helpers.rb:33:in `map' /home/runner/work/gollum/gollum/lib/gollum/views/helpers/locale_helpers.rb:33:in `autofill' /home/runner/work/gollum/gollum/lib/gollum/views/helpers/locale_helpers.rb:21:in `t' /home/runner/work/gollum/gollum/test/gollum/views/test_locale_helper.rb:95:in `block (4 levels) in ' `#gsub!` attempts to modify a string in-place, which does not work when a string is frozen. It seems that in some Ruby environments, strings from YAML files are frozen. --- lib/gollum/views/helpers/locale_helpers.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/gollum/views/helpers/locale_helpers.rb b/lib/gollum/views/helpers/locale_helpers.rb index 2f9fb2e7..da15bc76 100644 --- a/lib/gollum/views/helpers/locale_helpers.rb +++ b/lib/gollum/views/helpers/locale_helpers.rb @@ -42,7 +42,7 @@ module Precious end def fill_argument_content(i18n_key, i18n_value) - i18n_value.gsub!(YAML_VARIABLE_REGEXP) do |argument| + i18n_value = i18n_value.gsub(YAML_VARIABLE_REGEXP) do |argument| method_name = argument.gsub(/[^\w]/, '') next if method_name.nil?