From 8cc97601c45d9efaa22c11e5961b3883132e312e Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Fri, 23 Sep 2016 22:32:32 +0200 Subject: [PATCH] scourXmlFile(): Set specified 'filename' as input filename so relative references will work --- scour/scour.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scour/scour.py b/scour/scour.py index 2ae8230..e91d385 100644 --- a/scour/scour.py +++ b/scour/scour.py @@ -3519,10 +3519,17 @@ def scourString(in_string, options=None): # input is a filename # returns the minidom doc representation of the SVG def scourXmlFile(filename, options=None): + # we need to set infilename (otherwise relative references in the SVG won't work) + if options is None: + options = generateDefaultOptions() + options.infilename = filename + + # open the file and scour it with open(filename, "rb") as f: in_string = f.read() out_string = scourString(in_string, options) + # prepare the output xml.dom.minidom object doc = xml.dom.minidom.parseString(out_string.encode('utf-8')) # since minidom does not seem to parse DTDs properly