From 90825d290a4dedfda9584ff369b0b898b576fac1 Mon Sep 17 00:00:00 2001 From: 0penBrain <48731257+0penBrain@users.noreply.github.com> Date: Fri, 29 Nov 2019 22:57:42 +0100 Subject: [PATCH] Improve Inkscape version parsing in SVG import --- src/Mod/Draft/importSVG.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/Mod/Draft/importSVG.py b/src/Mod/Draft/importSVG.py index 18ab27f7e8..d798d767a4 100644 --- a/src/Mod/Draft/importSVG.py +++ b/src/Mod/Draft/importSVG.py @@ -714,18 +714,17 @@ class svgHandler(xml.sax.ContentHandler): if self.count == 1 and name == 'svg': if 'inkscape:version' in data: inks_doc_name = attrs.getValue('sodipodi:docname') - inks_full_ver = attrs.getValue('inkscape:version')[:4] - inks_full_ver_list = inks_full_ver.split('.') - _maj = int(inks_full_ver_list[0]) - _min = int(inks_full_ver_list[1]) - + inks_full_ver = attrs.getValue('inkscape:version') + inks_ver_pars = re.search("\d+\.\d+", inks_full_ver) + if inks_ver_pars != None: + inks_ver_f = float(inks_ver_pars.group(0)) + else: + inks_ver_f = 99.99 # Inkscape before 0.92 used 90 dpi as resolution # Newer versions use 96 dpi - if _maj == 0 and _min > 91: - self.svgdpi = 96.0 - elif _maj == 0 and _min < 92: + if inks_ver_f < 0.92: self.svgdpi = 90.0 - elif _maj > 0: + else: self.svgdpi = 96.0 if 'inkscape:version' not in data: _msg = ("This SVG file does not appear to have been produced "