Commit e1064f16 authored by Douwe Maan's avatar Douwe Maan

Merge branch '55116-runtimeerror-can-t-modify-frozen-string' into 'master'

Fix a frozen string error in lib/gitlab/utils.rb

Closes #55116

See merge request gitlab-org/gitlab-ce!23690
parents eadd53b9 f233c3bc
---
title: Fix a frozen string error in lib/gitlab/utils.rb
merge_request: 23690
author:
type: fixed
...@@ -60,7 +60,7 @@ module Gitlab ...@@ -60,7 +60,7 @@ module Gitlab
# Converts newlines into HTML line break elements # Converts newlines into HTML line break elements
def nlbr(str) 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 end
def remove_line_breaks(str) def remove_line_breaks(str)
......
...@@ -44,6 +44,12 @@ describe Gitlab::Utils do ...@@ -44,6 +44,12 @@ describe Gitlab::Utils do
end end
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 describe '.remove_line_breaks' do
using RSpec::Parameterized::TableSyntax using RSpec::Parameterized::TableSyntax
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment