Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec/lib
diff options
context:
space:
mode:
authorSean McGivern <sean@gitlab.com>2018-03-28 14:56:11 +0300
committerSean McGivern <sean@gitlab.com>2018-03-28 16:23:47 +0300
commit3a43cf426af6433ec8d5597da902f1081866796d (patch)
treee41e4714d2a0b4bcc6abf20057a3b5d46448a5c8 /spec/lib
parentcb94afc561c08db1b2312020e9d0a3e2f5837494 (diff)
Fix auto-linking with escaped HTML entities
We displayed the correct text as the link text (without double-encoding), but didn't do the same for the actual link target, so any link containing an ampersand would break when auto-linked.
Diffstat (limited to 'spec/lib')
-rw-r--r--spec/lib/banzai/filter/autolink_filter_spec.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/spec/lib/banzai/filter/autolink_filter_spec.rb b/spec/lib/banzai/filter/autolink_filter_spec.rb
index cbb0089bde7..a50329473ad 100644
--- a/spec/lib/banzai/filter/autolink_filter_spec.rb
+++ b/spec/lib/banzai/filter/autolink_filter_spec.rb
@@ -167,6 +167,15 @@ describe Banzai::Filter::AutolinkFilter do
expect(actual).to eq(expected_complicated_link)
end
+ it 'does not double-encode HTML entities' do
+ encoded_link = "#{link}?foo=bar&amp;baz=quux"
+ expected_encoded_link = %Q{<a href="#{encoded_link}">#{encoded_link}</a>}
+ actual = unescape(filter(encoded_link).to_html)
+
+ expect(actual).to eq(Rinku.auto_link(encoded_link))
+ expect(actual).to eq(expected_encoded_link)
+ end
+
it 'does not include trailing HTML entities' do
doc = filter("See &lt;&lt;&lt;#{link}&gt;&gt;&gt;")