Skip to content

Commit

Permalink
Merge branch 'mastodon:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
DismalShadowX authored Jul 4, 2024
2 parents 4e3d87a + 47f0fae commit ba43757
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/sanitize_ext/sanitize_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ module Config
end

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: {
'a' => %w(href rel class translate),
Expand Down
8 changes: 8 additions & 0 deletions spec/lib/html_aware_formatter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@
expect(subject).to_not include 'status__content__spoiler-link'
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
8 changes: 8 additions & 0 deletions spec/lib/plain_text_formatter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@
expect(subject).to eq 'Lorem ipsum'
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
4 changes: 4 additions & 0 deletions spec/lib/sanitize/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
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

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
expect(Sanitize.fragment('<a>Test</a>', subject)).to eq 'Test'
end
Expand Down

0 comments on commit ba43757

Please sign in to comment.