From 8a2892b458a385dedcd19e21d53d136d467efb0f Mon Sep 17 00:00:00 2001 From: Niels Thykier Date: Sat, 21 Apr 2018 06:38:28 +0000 Subject: [PATCH] Avoid crashing on stdDeviation attribute Signed-off-by: Niels Thykier --- scour/scour.py | 3 ++- testscour.py | 12 +++++++++++- unittests/remove-default-attr-std-deviation.svg | 11 +++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 unittests/remove-default-attr-std-deviation.svg diff --git a/scour/scour.py b/scour/scour.py index e5346b8..3e5a8e5 100644 --- a/scour/scour.py +++ b/scour/scour.py @@ -1862,7 +1862,8 @@ default_attributes = [ DefaultAttribute('seed', 0, elements=['feTurbulence']), DefaultAttribute('specularConstant', 1, elements=['feSpecularLighting']), 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('surfaceScale', 1, elements=['feDiffuseLighting', 'feSpecularLighting']), DefaultAttribute('type', 'matrix', elements=['feColorMatrix']), diff --git a/testscour.py b/testscour.py index 2c25258..c182a35 100755 --- a/testscour.py +++ b/testscour.py @@ -1577,7 +1577,17 @@ class RemoveDefaultAttributeOrderSVGLengthCrash(unittest.TestCase): try: scourXmlFile('unittests/remove-default-attr-order.svg') except AttributeError: - 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): diff --git a/unittests/remove-default-attr-std-deviation.svg b/unittests/remove-default-attr-std-deviation.svg new file mode 100644 index 0000000..ba88368 --- /dev/null +++ b/unittests/remove-default-attr-std-deviation.svg @@ -0,0 +1,11 @@ + + + + + + + + + +