mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-09 17:15:18 +00:00
Implement HTML ruby tags for east-asian languages (#30897)
This commit is contained in:
parent
9be77fc0db
commit
47f0faebc9
|
@ -65,7 +65,7 @@ class Sanitize
|
||||||
end
|
end
|
||||||
|
|
||||||
MASTODON_STRICT = freeze_config(
|
MASTODON_STRICT = freeze_config(
|
||||||
elements: %w(p br span a del pre blockquote code b strong u i em ul ol li),
|
elements: %w(p br span a del pre blockquote code b strong u i em ul ol li ruby rt rp),
|
||||||
|
|
||||||
attributes: {
|
attributes: {
|
||||||
'a' => %w(href rel class translate),
|
'a' => %w(href rel class translate),
|
||||||
|
|
|
@ -41,6 +41,14 @@ RSpec.describe HtmlAwareFormatter do
|
||||||
expect(subject).to_not include 'status__content__spoiler-link'
|
expect(subject).to_not include 'status__content__spoiler-link'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when given text containing ruby tags for east-asian languages' do
|
||||||
|
let(:text) { '<ruby>明日 <rp>(</rp><rt>Ashita</rt><rp>)</rp></ruby>' }
|
||||||
|
|
||||||
|
it 'keeps the ruby tags' do
|
||||||
|
expect(subject).to eq '<ruby>明日 <rp>(</rp><rt>Ashita</rt><rp>)</rp></ruby>'
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -72,6 +72,14 @@ RSpec.describe PlainTextFormatter do
|
||||||
expect(subject).to eq 'Lorem ipsum'
|
expect(subject).to eq 'Lorem ipsum'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when text contains HTML ruby tags' do
|
||||||
|
let(:status) { Fabricate(:status, account: remote_account, text: '<p>Lorem <ruby>明日 <rp>(</rp><rt>Ashita</rt><rp>)</rp></ruby> ipsum</p>') }
|
||||||
|
|
||||||
|
it 'strips the comment' do
|
||||||
|
expect(subject).to eq 'Lorem 明日 (Ashita) ipsum'
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -18,6 +18,10 @@ describe Sanitize::Config do
|
||||||
expect(Sanitize.fragment('<p>Check out:</p><ol start="3" reversed=""><li>Foo</li><li>Bar</li></ol>', subject)).to eq '<p>Check out:</p><ol start="3" reversed=""><li>Foo</li><li>Bar</li></ol>'
|
expect(Sanitize.fragment('<p>Check out:</p><ol start="3" reversed=""><li>Foo</li><li>Bar</li></ol>', subject)).to eq '<p>Check out:</p><ol start="3" reversed=""><li>Foo</li><li>Bar</li></ol>'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'keeps ruby tags' do
|
||||||
|
expect(Sanitize.fragment('<p><ruby>明日 <rp>(</rp><rt>Ashita</rt><rp>)</rp></ruby></p>', subject)).to eq '<p><ruby>明日 <rp>(</rp><rt>Ashita</rt><rp>)</rp></ruby></p>'
|
||||||
|
end
|
||||||
|
|
||||||
it 'removes a without href' do
|
it 'removes a without href' do
|
||||||
expect(Sanitize.fragment('<a>Test</a>', subject)).to eq 'Test'
|
expect(Sanitize.fragment('<a>Test</a>', subject)).to eq 'Test'
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue