Signed-off-by: Niels Thykier <niels@thykier.net>
This commit is contained in:
parent
92e64f0d7f
commit
b8a071f995
4 changed files with 49 additions and 30 deletions
|
|
@ -1200,11 +1200,11 @@ def mergeSiblingGroupsWithCommonAttributes(elem):
|
|||
for node in nodes:
|
||||
if node.nodeType == Node.ELEMENT_NODE and node.nodeName == 'g' and node.namespaceURI == NS['SVG']:
|
||||
# Merge
|
||||
primaryGroup.childNodes.extend(node.childNodes)
|
||||
node.childNodes = []
|
||||
for child in node.childNodes[:]:
|
||||
primaryGroup.appendChild(child)
|
||||
elem.removeChild(node).unlink()
|
||||
else:
|
||||
primaryGroup.childNodes.append(node)
|
||||
elem.childNodes.remove(node)
|
||||
primaryGroup.appendChild(node)
|
||||
|
||||
# each child gets the same treatment, recursively
|
||||
for childNode in elem.childNodes:
|
||||
|
|
|
|||
|
|
@ -2099,6 +2099,12 @@ class GroupSiblingMerge(unittest.TestCase):
|
|||
self.assertEqual(doc.getElementsByTagName('g').length, 8,
|
||||
'Sibling merging is disabled by --disable-group-collapsing')
|
||||
|
||||
def test_sibling_merge_crash(self):
|
||||
doc = scourXmlFile('unittests/group-sibling-merge-crash.svg',
|
||||
parse_args(['']))
|
||||
self.assertEqual(doc.getElementsByTagName('g').length, 1,
|
||||
'Sibling merge should work without causing crashes')
|
||||
|
||||
|
||||
class GroupCreation(unittest.TestCase):
|
||||
|
||||
|
|
|
|||
13
unittests/group-sibling-merge-crash.svg
Normal file
13
unittests/group-sibling-merge-crash.svg
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0" y="0" viewBox="0 0 141.732 141.732" xml:space="preserve">
|
||||
<g>
|
||||
<g clip-path="url(#SVGID_2_)">
|
||||
<path d="M1,1" fill="#fdebc8" stroke="#000" stroke-width=".5" stroke-miterlimit="10"/>
|
||||
</g>
|
||||
<g clip-path="url(#SVGID_2_)">
|
||||
<g>
|
||||
<path opacity=".5" clip-path="url(#SVGID_4_)" fill="#fff" d="M1,1"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 528 B |
Loading…
Add table
Add a link
Reference in a new issue