mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
FIX: Allow svg in oneboxer in certain cases (#19253)
When doing local oneboxes we sometimes want to allow SVGs in the final preview HTML. The main case currently is for the new cooked hashtags, which include an SVG icon. SVGs will be included in local oneboxes via `ExcerptParser` _only_ if they have the d-icon class, and if the caller for `post.excerpt` specifies the `keep_svg: true` option.
This commit is contained in:
@ -34,6 +34,18 @@ RSpec.describe ExcerptParser do
|
||||
expect(ExcerptParser.get_excerpt(html, 2, {})).to match_html('<details class="disabled"><summary>fo…</summary></details>')
|
||||
end
|
||||
|
||||
it "allows <svg> with <use> inside for icons when keep_svg is true" do
|
||||
html = '<svg class="fa d-icon d-icon-folder svg-icon svg-node"><use href="#folder"></use></svg>'
|
||||
expect(ExcerptParser.get_excerpt(html, 100, { keep_svg: true })).to match_html('<svg class="fa d-icon d-icon-folder svg-icon svg-node"><use href="#folder"></use></svg>')
|
||||
expect(ExcerptParser.get_excerpt(html, 100, {})).to match_html('')
|
||||
|
||||
html = '<svg class="blah"><use href="#folder"></use></svg>'
|
||||
expect(ExcerptParser.get_excerpt(html, 100, { keep_svg: true })).to match_html('')
|
||||
|
||||
html = '<use href="#user"></use><svg class="fa d-icon d-icon-folder svg-icon svg-node"><use href="#folder"></use></svg>'
|
||||
expect(ExcerptParser.get_excerpt(html, 100, { keep_svg: true })).to match_html('<svg class="fa d-icon d-icon-folder svg-icon svg-node"><use href="#folder"></use></svg>')
|
||||
end
|
||||
|
||||
describe "keep_onebox_body parameter" do
|
||||
it "keeps the body content for external oneboxes" do
|
||||
html = <<~HTML.strip
|
||||
|
Reference in New Issue
Block a user