diff options
-rw-r--r-- | changelogs/unreleased/55116-runtimeerror-can-t-modify-frozen-string.yml | 5 | ||||
-rw-r--r-- | lib/gitlab/utils.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/utils_spec.rb | 6 |
3 files changed, 12 insertions, 1 deletions
diff --git a/changelogs/unreleased/55116-runtimeerror-can-t-modify-frozen-string.yml b/changelogs/unreleased/55116-runtimeerror-can-t-modify-frozen-string.yml new file mode 100644 index 00000000000..a98e70465b2 --- /dev/null +++ b/changelogs/unreleased/55116-runtimeerror-can-t-modify-frozen-string.yml @@ -0,0 +1,5 @@ +--- +title: Fix a frozen string error in lib/gitlab/utils.rb +merge_request: 23690 +author: +type: fixed diff --git a/lib/gitlab/utils.rb b/lib/gitlab/utils.rb index 26fc56227a2..a81cee0d6d2 100644 --- a/lib/gitlab/utils.rb +++ b/lib/gitlab/utils.rb @@ -60,7 +60,7 @@ module Gitlab # Converts newlines into HTML line break elements def nlbr(str) - ActionView::Base.full_sanitizer.sanitize(str, tags: []).gsub(/\r?\n/, '<br>').html_safe + ActionView::Base.full_sanitizer.sanitize(+str, tags: []).gsub(/\r?\n/, '<br>').html_safe end def remove_line_breaks(str) diff --git a/spec/lib/gitlab/utils_spec.rb b/spec/lib/gitlab/utils_spec.rb index 47a5fd0bdb4..f5a4b7e2ebf 100644 --- a/spec/lib/gitlab/utils_spec.rb +++ b/spec/lib/gitlab/utils_spec.rb @@ -44,6 +44,12 @@ describe Gitlab::Utils do end end + describe '.nlbr' do + it 'replaces new lines with <br>' do + expect(described_class.nlbr("<b>hello</b>\n<i>world</i>".freeze)).to eq("hello<br>world") + end + end + describe '.remove_line_breaks' do using RSpec::Parameterized::TableSyntax |