summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Hegyi <ahegyi@gitlab.com>2019-06-19 07:48:19 +0200
committerAdam Hegyi <ahegyi@gitlab.com>2019-06-19 07:53:15 +0200
commit20e2766d9aeb8d4175e8976ccddbba17597a422b (patch)
tree1bfe0de1d3eb10153e0b5a1a7e054ba055ba2742
parentcd17f804d51751870f71e3bab57feeb9ab75da38 (diff)
downloadgitlab-ce-fix-bug-63406.tar.gz
Fix copying a single line from Firefoxfix-bug-63406
This change ensures that all open <span> tags are closed before adding a <br> tag. Fixes #63406
-rw-r--r--lib/gitlab/ci/ansi2html.rb4
-rw-r--r--spec/lib/gitlab/ci/ansi2html_spec.rb8
2 files changed, 7 insertions, 5 deletions
diff --git a/lib/gitlab/ci/ansi2html.rb b/lib/gitlab/ci/ansi2html.rb
index 6109b45ffd2..10d8c326c9a 100644
--- a/lib/gitlab/ci/ansi2html.rb
+++ b/lib/gitlab/ci/ansi2html.rb
@@ -200,7 +200,9 @@ module Gitlab
css_classes = %w[section line] + sections.map { |section| "s_#{section}" }
end
- write_in_tag %{<br/>}
+ ensure_open_new_tag
+ write_raw %{<br/>}
+ close_open_tags
write_raw %{<span class="#{css_classes.join(' ')}"></span>} if css_classes.any?
@lineno_in_section += 1
open_new_tag
diff --git a/spec/lib/gitlab/ci/ansi2html_spec.rb b/spec/lib/gitlab/ci/ansi2html_spec.rb
index ac4612dda92..655c5d20d7f 100644
--- a/spec/lib/gitlab/ci/ansi2html_spec.rb
+++ b/spec/lib/gitlab/ci/ansi2html_spec.rb
@@ -141,11 +141,11 @@ describe Gitlab::Ci::Ansi2html do
end
it "replaces newlines with line break tags" do
- expect(convert_html("\n")).to eq('<span class=""><br/><span class=""></span></span>')
+ expect(convert_html("\n")).to eq('<span class=""></span><br/><span class=""></span>')
end
it "groups carriage returns with newlines" do
- expect(convert_html("\r\n")).to eq('<span class=""><br/><span class=""></span></span>')
+ expect(convert_html("\r\n")).to eq('<span class=""></span><br/><span class=""></span>')
end
describe "incremental update" do
@@ -193,7 +193,7 @@ describe Gitlab::Ci::Ansi2html do
let(:pre_text) { "Hello\r" }
let(:pre_html) { "<span class=\"\">Hello\r</span>" }
let(:text) { "\nWorld" }
- let(:html) { "<span class=\"\"><br/><span class=\"\">World</span></span>" }
+ let(:html) { "<span class=\"\"></span><br/><span class=\"\">World</span>" }
it_behaves_like 'stateable converter'
end
@@ -232,7 +232,7 @@ describe Gitlab::Ci::Ansi2html do
it 'prints light red' do
text = "#{section_start}\e[91mHello\e[0m\n#{section_end}"
header = %{<span class="term-fg-l-red section js-section-header js-s-#{class_name(section_name)}">Hello</span>}
- line_break = %{<span class="section js-section-header js-s-#{class_name(section_name)}"><br/></span>}
+ line_break = %{<span class="section js-section-header js-s-#{class_name(section_name)}"></span><br/>}
line = %{<span class="section line s_#{class_name(section_name)}"></span>}
empty_line = %{<span class="section js-s-#{class_name(section_name)}"></span>}
html = "#{section_start_html}#{header}#{line_break}#{line}#{empty_line}#{section_end_html}"