Fix Issue 479669: Handle empty styl elements
This commit is contained in:
parent
99dfb0f819
commit
7e8d777639
3 changed files with 20 additions and 6 deletions
12
scour.py
12
scour.py
|
|
@ -420,12 +420,12 @@ def findReferencedElements(node, ids=None):
|
||||||
# if this node is a style element, parse its text into CSS
|
# if this node is a style element, parse its text into CSS
|
||||||
if node.nodeName == 'style' and node.namespaceURI == NS['SVG']:
|
if node.nodeName == 'style' and node.namespaceURI == NS['SVG']:
|
||||||
# node.firstChild will be either a CDATA or a Text node
|
# node.firstChild will be either a CDATA or a Text node
|
||||||
cssRules = parseCssString(node.firstChild.nodeValue)
|
if node.firstChild != None:
|
||||||
for rule in cssRules:
|
cssRules = parseCssString(node.firstChild.nodeValue)
|
||||||
for propname in rule['properties']:
|
for rule in cssRules:
|
||||||
propval = rule['properties'][propname]
|
for propname in rule['properties']:
|
||||||
findReferencingProperty(node, propname, propval, ids)
|
propval = rule['properties'][propname]
|
||||||
|
findReferencingProperty(node, propname, propval, ids)
|
||||||
return ids
|
return ids
|
||||||
|
|
||||||
# else if xlink:href is set, then grab the id
|
# else if xlink:href is set, then grab the id
|
||||||
|
|
|
||||||
10
testscour.py
10
testscour.py
|
|
@ -957,6 +957,16 @@ class EnsurePreserveWhitespaceOnNonTextElements(unittest.TestCase):
|
||||||
self.assertEquals( s.count('\n'), 5,
|
self.assertEquals( s.count('\n'), 5,
|
||||||
'Did not properly preserve whitespace on elements even if they were not textual')
|
'Did not properly preserve whitespace on elements even if they were not textual')
|
||||||
|
|
||||||
|
class HandleEmptyStyleElement(unittest.TestCase):
|
||||||
|
def runTest(self):
|
||||||
|
try:
|
||||||
|
styles = scour.scourXmlFile('unittests/empty-style.svg').getElementsByTagNameNS(SVGNS, 'style')
|
||||||
|
fail = len(styles) != 1
|
||||||
|
except AttributeError:
|
||||||
|
fail = True
|
||||||
|
self.assertEquals( fail, False,
|
||||||
|
'Could not handle an empty style element')
|
||||||
|
|
||||||
# TODO; write a test for embedding rasters
|
# TODO; write a test for embedding rasters
|
||||||
# TODO: write a test for --disable-embed-rasters
|
# TODO: write a test for --disable-embed-rasters
|
||||||
# TODO: write tests for --keep-editor-data
|
# TODO: write tests for --keep-editor-data
|
||||||
|
|
|
||||||
4
unittests/empty-style.svg
Normal file
4
unittests/empty-style.svg
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
<?xml version="1.0" ?>
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<style id="style1" />
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 96 B |
Loading…
Add table
Add a link
Reference in a new issue