.
This commit is contained in:
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
|
||||
<name>Remove Obsolete Attributes</name>
|
||||
<id>fablabchemnitz.de.remove_obsolete_attributes</id>
|
||||
<label>Remove attributes "sodipodi:absref", "sodipodi:docbase" and "sodipodi:docname" from all elements that contain them. These attributes contain absolute paths to resources which can pose a security issue.</label>
|
||||
<param name="removeAbsref" type="bool" gui-text="Remove sodipodi:absref">true</param>
|
||||
<param name="removeDocbase" type="bool" gui-text="Remove sodipodi:docbase">true</param>
|
||||
<param name="removeDocname" type="bool" gui-text="Remove sodipodi:docname">true</param>
|
||||
<effect>
|
||||
<object-type>all</object-type>
|
||||
<effects-menu>
|
||||
<submenu name="FabLab Chemnitz">
|
||||
<submenu name="Various"/>
|
||||
</submenu>
|
||||
</effects-menu>
|
||||
</effect>
|
||||
<script>
|
||||
<command location="inx" interpreter="python">remove_obsolete_attributes.py</command>
|
||||
</script>
|
||||
</inkscape-extension>
|
@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
"""
|
||||
Removes attributes sodipodi:absref, sodipodi:docbase and sodipodi:docname from all elements that contain them.
|
||||
|
||||
full names of attributes
|
||||
sodipodi:absref
|
||||
{http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd}absref
|
||||
sodipodi:docbase
|
||||
{http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd}docbase
|
||||
sodipodi:docname
|
||||
{http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd}docname
|
||||
|
||||
element.attrib.pop("{http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd}absref", None)
|
||||
"""
|
||||
|
||||
import inkex
|
||||
import sys
|
||||
|
||||
class RemoveObsoleteAttributes(inkex.EffectExtension):
|
||||
def __init__(self):
|
||||
inkex.Effect.__init__(self)
|
||||
self.arg_parser.add_argument("-a", "--removeAbsref", type=inkex.Boolean, default=True, help="Remove sodipodi:absref")
|
||||
self.arg_parser.add_argument("-b", "--removeDocbase", type=inkex.Boolean, default=True, help="Remove sodipodi:docbase")
|
||||
self.arg_parser.add_argument("-n", "--removeDocname", type=inkex.Boolean, default=True, help="Remove sodipodi:docname")
|
||||
|
||||
def effect(self):
|
||||
if self.options.removeAbsref:
|
||||
elements = self.document.xpath("//*[@sodipodi:absref]", namespaces=inkex.NSS)
|
||||
for element in elements:
|
||||
element.attrib.pop("{http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd}absref", None)
|
||||
|
||||
if self.options.removeDocbase:
|
||||
elements = self.document.xpath("//*[@sodipodi:docbase]", namespaces=inkex.NSS)
|
||||
for element in elements:
|
||||
element.attrib.pop("{http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd}docbase", None)
|
||||
|
||||
if self.options.removeDocname:
|
||||
elements = self.document.xpath("//*[@sodipodi:docname]", namespaces=inkex.NSS)
|
||||
for element in elements:
|
||||
element.attrib.pop("{http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd}docname", None)
|
||||
|
||||
if __name__ == "__main__":
|
||||
RemoveObsoleteAttributes().run()
|
Reference in New Issue
Block a user