Merge pull request #192 from nthykier/gh-189-order-vs-SVGLength
Work around an exception in removeDefaultAttributeValue() caused by some rarely used filter attributes that allow an optional second value which SVGLength does not handle properly
This commit is contained in:
commit
8c95d950af
4 changed files with 49 additions and 3 deletions
|
|
@ -1830,9 +1830,12 @@ default_attributes = [
|
||||||
DefaultAttribute('spreadMethod', 'pad', elements=['linearGradient', 'radialGradient']),
|
DefaultAttribute('spreadMethod', 'pad', elements=['linearGradient', 'radialGradient']),
|
||||||
|
|
||||||
# filter effects
|
# filter effects
|
||||||
|
# TODO: Some numerical attributes allow an optional second value ("number-optional-number")
|
||||||
|
# and are currently handled as strings to avoid an exception in 'SVGLength', see
|
||||||
|
# https://github.com/scour-project/scour/pull/192
|
||||||
DefaultAttribute('amplitude', 1, elements=['feFuncA', 'feFuncB', 'feFuncG', 'feFuncR']),
|
DefaultAttribute('amplitude', 1, elements=['feFuncA', 'feFuncB', 'feFuncG', 'feFuncR']),
|
||||||
DefaultAttribute('azimuth', 0, elements=['feDistantLight']),
|
DefaultAttribute('azimuth', 0, elements=['feDistantLight']),
|
||||||
DefaultAttribute('baseFrequency', 0, elements=['feFuncA', 'feFuncB', 'feFuncG', 'feFuncR']),
|
DefaultAttribute('baseFrequency', '0', elements=['feFuncA', 'feFuncB', 'feFuncG', 'feFuncR']),
|
||||||
DefaultAttribute('bias', 1, elements=['feConvolveMatrix']),
|
DefaultAttribute('bias', 1, elements=['feConvolveMatrix']),
|
||||||
DefaultAttribute('diffuseConstant', 1, elements=['feDiffuseLighting']),
|
DefaultAttribute('diffuseConstant', 1, elements=['feDiffuseLighting']),
|
||||||
DefaultAttribute('edgeMode', 'duplicate', elements=['feConvolveMatrix']),
|
DefaultAttribute('edgeMode', 'duplicate', elements=['feConvolveMatrix']),
|
||||||
|
|
@ -1848,16 +1851,17 @@ default_attributes = [
|
||||||
DefaultAttribute('offset', 0, elements=['feFuncA', 'feFuncB', 'feFuncG', 'feFuncR']),
|
DefaultAttribute('offset', 0, elements=['feFuncA', 'feFuncB', 'feFuncG', 'feFuncR']),
|
||||||
DefaultAttribute('operator', 'over', elements=['feComposite']),
|
DefaultAttribute('operator', 'over', elements=['feComposite']),
|
||||||
DefaultAttribute('operator', 'erode', elements=['feMorphology']),
|
DefaultAttribute('operator', 'erode', elements=['feMorphology']),
|
||||||
DefaultAttribute('order', 3, elements=['feConvolveMatrix']),
|
DefaultAttribute('order', '3', elements=['feConvolveMatrix']),
|
||||||
DefaultAttribute('pointsAtX', 0, elements=['feSpotLight']),
|
DefaultAttribute('pointsAtX', 0, elements=['feSpotLight']),
|
||||||
DefaultAttribute('pointsAtY', 0, elements=['feSpotLight']),
|
DefaultAttribute('pointsAtY', 0, elements=['feSpotLight']),
|
||||||
DefaultAttribute('pointsAtZ', 0, elements=['feSpotLight']),
|
DefaultAttribute('pointsAtZ', 0, elements=['feSpotLight']),
|
||||||
DefaultAttribute('preserveAlpha', 'false', elements=['feConvolveMatrix']),
|
DefaultAttribute('preserveAlpha', 'false', elements=['feConvolveMatrix']),
|
||||||
|
DefaultAttribute('radius', '0', elements=['feMorphology']),
|
||||||
DefaultAttribute('scale', 0, elements=['feDisplacementMap']),
|
DefaultAttribute('scale', 0, elements=['feDisplacementMap']),
|
||||||
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']),
|
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']),
|
||||||
|
|
|
||||||
20
testscour.py
20
testscour.py
|
|
@ -1570,6 +1570,26 @@ class RemoveDefaultGradFYValue(unittest.TestCase):
|
||||||
'fy matching cy not removed')
|
'fy matching cy not removed')
|
||||||
|
|
||||||
|
|
||||||
|
class RemoveDefaultAttributeOrderSVGLengthCrash(unittest.TestCase):
|
||||||
|
|
||||||
|
# Triggered a crash in v0.36
|
||||||
|
def runTest(self):
|
||||||
|
try:
|
||||||
|
scourXmlFile('unittests/remove-default-attr-order.svg')
|
||||||
|
except 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):
|
||||||
|
|
|
||||||
11
unittests/remove-default-attr-order.svg
Normal file
11
unittests/remove-default-attr-order.svg
Normal 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%">
|
||||||
|
<feConvolveMatrix order="3 1" kernelMatrix="0.3333 0.3333 0.3333" kernelUnitLength="3 1" edgeMode="none"/>
|
||||||
|
</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: 585 B |
11
unittests/remove-default-attr-std-deviation.svg
Normal file
11
unittests/remove-default-attr-std-deviation.svg
Normal 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 |
Loading…
Add table
Add a link
Reference in a new issue