Resolve "User profile activity feed contains broken image links"

This commit is contained in:
Tim Zallmann 2017-08-21 09:45:46 +00:00 committed by Phil Hughes
parent 6509833cfa
commit 2bfee0706a
2 changed files with 7 additions and 1 deletions

View file

@ -176,7 +176,7 @@ module EventsHelper
sanitize( sanitize(
text, text,
tags: %w(a img gl-emoji b pre code p span), tags: %w(a img gl-emoji b pre code p span),
attributes: Rails::Html::WhiteListSanitizer.allowed_attributes + ['style', 'data-name', 'data-unicode-version'] attributes: Rails::Html::WhiteListSanitizer.allowed_attributes + ['style', 'data-src', 'data-name', 'data-unicode-version']
) )
end end

View file

@ -62,6 +62,12 @@ describe EventsHelper do
expect(helper.event_note(input)).to eq(expected) expect(helper.event_note(input)).to eq(expected)
end end
it 'preserves data-src for lazy images' do
input = "![ImageTest](/uploads/test.png)"
image_url = "data-src=\"/uploads/test.png\""
expect(helper.event_note(input)).to match(image_url)
end
context 'labels formatting' do context 'labels formatting' do
let(:input) { 'this should be ~label_1' } let(:input) { 'this should be ~label_1' }