Avoid crashing on stdDeviation attribute

Signed-off-by: Niels Thykier <niels@thykier.net>
This commit is contained in:
Niels Thykier 2018-04-21 06:38:28 +00:00
parent c504891bd7
commit 8a2892b458
3 changed files with 24 additions and 2 deletions

View file

@ -1862,7 +1862,8 @@ default_attributes = [
DefaultAttribute('seed', 0, elements=['feTurbulence']), DefaultAttribute('seed', 0, elements=['feTurbulence']),
DefaultAttribute('specularConstant', 1, elements=['feSpecularLighting']), DefaultAttribute('specularConstant', 1, elements=['feSpecularLighting']),
DefaultAttribute('specularExponent', 1, elements=['feSpecularLighting', 'feSpotLight']), DefaultAttribute('specularExponent', 1, elements=['feSpecularLighting', 'feSpotLight']),
DefaultAttribute('stdDeviation', 0, elements=['feGaussianBlur']), # Pretend it is a string (for the same reasons as we do with "order")
DefaultAttribute('stdDeviation', '0', elements=['feGaussianBlur']),
DefaultAttribute('stitchTiles', 'noStitch', elements=['feTurbulence']), DefaultAttribute('stitchTiles', 'noStitch', elements=['feTurbulence']),
DefaultAttribute('surfaceScale', 1, elements=['feDiffuseLighting', 'feSpecularLighting']), DefaultAttribute('surfaceScale', 1, elements=['feDiffuseLighting', 'feSpecularLighting']),
DefaultAttribute('type', 'matrix', elements=['feColorMatrix']), DefaultAttribute('type', 'matrix', elements=['feColorMatrix']),

View file

@ -1580,6 +1580,16 @@ class RemoveDefaultAttributeOrderSVGLengthCrash(unittest.TestCase):
self.fail("Processing the order attribute triggered an AttributeError") self.fail("Processing the order attribute triggered an AttributeError")
class RemoveDefaultAttributeStdDeviationSVGLengthCrash(unittest.TestCase):
# Triggered a crash in v0.36
def runTest(self):
try:
scourXmlFile('unittests/remove-default-attr-std-deviation.svg')
except AttributeError:
self.fail("Processing the order attribute triggered an AttributeError")
class CDATAInXml(unittest.TestCase): class CDATAInXml(unittest.TestCase):
def runTest(self): def runTest(self):

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink= "http://www.w3.org/1999/xlink">
<defs>
<filter id="filter" filterUnits="objectBoundingBox" x="0%" y="0%" width="100%" height="100%">
<feGaussianBlur stdDeviation="0 0" x="10" y="10" dx="20" dy="20" />
</filter>
</defs>
<!-- Use the filter (otherwise, scour discards it before it trips over it) -->
<image id="png" x="10" y="30" width="150" height="50" xlink:href="raster.png"
filter="url(#filter)"/>
</svg>

After

Width:  |  Height:  |  Size: 546 B