Merge remote-tracking branch 'parent/main' into upstream-20241216
This commit is contained in:
commit
3784ad273c
555 changed files with 7564 additions and 3363 deletions
|
@ -39,15 +39,15 @@ RSpec.describe Sanitize::Config do
|
|||
end
|
||||
|
||||
it 'keeps a with href' do
|
||||
expect(Sanitize.fragment('<a href="http://example.com">Test</a>', subject)).to eq '<a href="http://example.com" rel="nofollow noopener noreferrer" target="_blank">Test</a>'
|
||||
expect(Sanitize.fragment('<a href="http://example.com">Test</a>', subject)).to eq '<a href="http://example.com" rel="nofollow noopener" target="_blank">Test</a>'
|
||||
end
|
||||
|
||||
it 'keeps a with translate="no"' do
|
||||
expect(Sanitize.fragment('<a href="http://example.com" translate="no">Test</a>', subject)).to eq '<a href="http://example.com" translate="no" rel="nofollow noopener noreferrer" target="_blank">Test</a>'
|
||||
expect(Sanitize.fragment('<a href="http://example.com" translate="no">Test</a>', subject)).to eq '<a href="http://example.com" translate="no" rel="nofollow noopener" target="_blank">Test</a>'
|
||||
end
|
||||
|
||||
it 'removes "translate" attribute with invalid value' do
|
||||
expect(Sanitize.fragment('<a href="http://example.com" translate="foo">Test</a>', subject)).to eq '<a href="http://example.com" rel="nofollow noopener noreferrer" target="_blank">Test</a>'
|
||||
expect(Sanitize.fragment('<a href="http://example.com" translate="foo">Test</a>', subject)).to eq '<a href="http://example.com" rel="nofollow noopener" target="_blank">Test</a>'
|
||||
end
|
||||
|
||||
it 'removes a with unparsable href' do
|
||||
|
@ -55,7 +55,7 @@ RSpec.describe Sanitize::Config do
|
|||
end
|
||||
|
||||
it 'keeps a with supported scheme and no host' do
|
||||
expect(Sanitize.fragment('<a href="dweb:/a/foo">Test</a>', subject)).to eq '<a href="dweb:/a/foo" rel="nofollow noopener noreferrer" target="_blank">Test</a>'
|
||||
expect(Sanitize.fragment('<a href="dweb:/a/foo">Test</a>', subject)).to eq '<a href="dweb:/a/foo" rel="nofollow noopener" target="_blank">Test</a>'
|
||||
end
|
||||
|
||||
it 'sanitizes math to LaTeX' do
|
||||
|
|
|
@ -50,7 +50,7 @@ RSpec.describe TextFormatter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'when given a stand-alone google URL' do
|
||||
context 'when given a stand-alone Google URL' do
|
||||
let(:text) { 'http://google.com' }
|
||||
|
||||
it 'matches the full URL' do
|
||||
|
@ -280,6 +280,26 @@ RSpec.describe TextFormatter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'when given a lengthy URL' do
|
||||
let(:text) { 'lorem https://prepitaph.org/wip/web-dovespair/ ipsum' }
|
||||
|
||||
it 'truncates the URL' do
|
||||
expect(subject).to include '<span class="invisible">https://</span>'
|
||||
expect(subject).to include '<span class="ellipsis">prepitaph.org/wip/web-dovespai</span>'
|
||||
expect(subject).to include '<span class="invisible">r/</span>'
|
||||
end
|
||||
end
|
||||
|
||||
context 'when given a sufficiently short URL' do
|
||||
let(:text) { 'lorem https://prepitaph.org/wip/web-devspair/ ipsum' }
|
||||
|
||||
it 'does not truncate the URL' do
|
||||
expect(subject).to include '<span class="invisible">https://</span>'
|
||||
expect(subject).to include '<span class="">prepitaph.org/wip/web-devspair/</span>'
|
||||
expect(subject).to include '<span class="invisible"></span>'
|
||||
end
|
||||
end
|
||||
|
||||
context 'when given text containing a hashtag' do
|
||||
let(:text) { '#hashtag' }
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue