mirror of
https://github.com/lunaisnotaboy/mastodon.git
synced 2024-11-22 14:53:15 +00:00
Fixed bug that timeline can not be displayed by InvalidURIError (#2947)
This commit is contained in:
parent
2fba94b36e
commit
08e94d1b19
|
@ -92,6 +92,8 @@ class Formatter
|
||||||
rel: 'nofollow noopener',
|
rel: 'nofollow noopener',
|
||||||
}
|
}
|
||||||
Twitter::Autolink.send(:link_to_text, entity, link_html(entity[:url]), normalized_url, html_attrs)
|
Twitter::Autolink.send(:link_to_text, entity, link_html(entity[:url]), normalized_url, html_attrs)
|
||||||
|
rescue Addressable::URI::InvalidURIError
|
||||||
|
encode(entity[:url])
|
||||||
end
|
end
|
||||||
|
|
||||||
def link_to_mention(entity, mentions)
|
def link_to_mention(entity, mentions)
|
||||||
|
|
|
@ -123,6 +123,13 @@ RSpec.describe Formatter do
|
||||||
expect(subject).to match '<p><img src="javascript:alert('XSS');"></p>'
|
expect(subject).to match '<p><img src="javascript:alert('XSS');"></p>'
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
||||||
describe '#reformat' do
|
describe '#reformat' do
|
||||||
|
|
Loading…
Reference in a new issue