FIX: add support for style element in SVGs
This commit is contained in:
parent
0c14f0d0a0
commit
c256121833
|
@ -9,7 +9,7 @@ class UploadCreator
|
||||||
|
|
||||||
WHITELISTED_SVG_ELEMENTS ||= %w{
|
WHITELISTED_SVG_ELEMENTS ||= %w{
|
||||||
circle clippath defs ellipse g line linearGradient path polygon polyline
|
circle clippath defs ellipse g line linearGradient path polygon polyline
|
||||||
radialGradient rect stop svg text textpath tref tspan use
|
radialGradient rect stop style svg text textpath tref tspan use
|
||||||
}.each(&:freeze)
|
}.each(&:freeze)
|
||||||
|
|
||||||
# Available options
|
# Available options
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
<svg width="100" height="50">
|
<svg width="100" height="50">
|
||||||
<text x="25" y="25">Discourse</text>
|
<style>
|
||||||
|
.black { fill: #FFFFFF; }
|
||||||
|
</style>
|
||||||
|
<text class="black" x="25" y="25">Discourse</text>
|
||||||
</svg>
|
</svg>
|
||||||
|
|
Before Width: | Height: | Size: 76 B After Width: | Height: | Size: 141 B |
|
@ -45,6 +45,16 @@ describe Upload do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "supports <style> element in SVG" do
|
||||||
|
SiteSetting.authorized_extensions = "svg"
|
||||||
|
|
||||||
|
upload = UploadCreator.new(image_svg, image_svg_filename).create_for(user_id)
|
||||||
|
expect(upload.valid?).to eq(true)
|
||||||
|
|
||||||
|
path = Discourse.store.path_for(upload)
|
||||||
|
expect(File.read(path)).to match(/<style>/)
|
||||||
|
end
|
||||||
|
|
||||||
it "can reconstruct dimensions on demand" do
|
it "can reconstruct dimensions on demand" do
|
||||||
upload = UploadCreator.new(huge_image, "image.png").create_for(user_id)
|
upload = UploadCreator.new(huge_image, "image.png").create_for(user_id)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue