Skip to content
Snippets Groups Projects
Commit 08e94d1b authored by abcang's avatar abcang Committed by Eugen Rochko
Browse files

Fixed bug that timeline can not be displayed by InvalidURIError (#2947)

parent 2fba94b3
No related branches found
No related tags found
No related merge requests found
......@@ -92,6 +92,8 @@ class Formatter
rel: 'nofollow noopener',
}
Twitter::Autolink.send(:link_to_text, entity, link_html(entity[:url]), normalized_url, html_attrs)
rescue Addressable::URI::InvalidURIError
encode(entity[:url])
end
def link_to_mention(entity, mentions)
......
......@@ -123,6 +123,13 @@ RSpec.describe Formatter do
expect(subject).to match '<p>&lt;img src=&quot;javascript:alert(&apos;XSS&apos;);&quot;&gt;</p>'
end
end
context 'contains invalid URL' do
let(:local_text) { 'http://www\.google\.com' }
it 'has valid url' do
expect(subject).to eq '<p>http://www\.google\.com</p>'
end
end
end
describe '#reformat' do
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment