From 19685106ab3d3254bc870c4d653f508a155ffa81 Mon Sep 17 00:00:00 2001 From: Kevin Hendricks Date: Thu, 14 Dec 2023 09:55:18 -0500 Subject: [PATCH] update python quickparser to more properly handle mixed case svg tag names --- .../plugin_launchers/python/quickparser.py | 58 +++++++++++++++++++ .../plugin_launchers/python/wrapper.py | 2 +- 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/src/Resource_Files/plugin_launchers/python/quickparser.py b/src/Resource_Files/plugin_launchers/python/quickparser.py index fc3f57e82e..fd189eacfb 100644 --- a/src/Resource_Files/plugin_launchers/python/quickparser.py +++ b/src/Resource_Files/plugin_launchers/python/quickparser.py @@ -41,6 +41,57 @@ WHITESPACE_CHARS = (' ', '\n', '\r', '\t') +SVG_TAG_NAME_FIXUPS = { + 'altglyph' : 'altGlyph', + 'altglyphdef' : 'altGlyphDef', + 'altglyphitem' : 'altGlyphItem', + 'animatecolor' : 'animateColor', + 'animatemotion' : 'animateMotion', + 'animatetransform' : 'animateTransform', + 'clippath' : 'clipPath', + 'feblend' : 'feBlend', + 'fecolormatrix' : 'feColorMatrix', + 'fecomponenttransfer' : 'feComponentTransfer', + 'fecomposite' : 'feComposite', + 'feconvolvematrix' : 'feConvolveMatrix', + 'fediffuselighting' : 'feDiffuseLighting', + 'fedisplacementmap' : 'feDisplacementMap', + 'fedistantlight' : 'feDistantLight', + 'fedropshadow' : 'feDropShadow', + 'feflood' : 'feFlood', + 'fefunca' : 'feFuncA', + 'fefuncb' : 'feFuncB', + 'fefuncg' : 'feFuncG', + 'fefuncr' : 'feFuncR', + 'fegaussianblur' : 'feGaussianBlur', + 'feimage' : 'feImage', + 'femerge' : 'feMerge', + 'femergenode' : 'feMergeNode', + 'femorphology' : 'feMorphology', + 'feoffset' : 'feOffset', + 'fepointlight' : 'fePointLight', + 'fespecularlighting' : 'feSpecularLighting', + 'fespotlight' : 'feSpotLight', + 'fetile' : 'feTile', + 'feturbulence' : 'feTurbulence', + 'flowdiv' : 'flowDiv', # obsolete, do not use + 'flowimage' : 'flowImage', # obsolete, do not use + 'flowline' : 'flowLine', # obsolete, do not use + 'flowregion' : 'flowRegion', # obsolete, do not use + 'flowregionbreak' : 'flowRegionBreak', # obsolete, do not use + 'flowregionexclude' : 'flowRegionExclude', # obsolete, do not use + 'flowref' : 'flowRef', # obsolete, do not use + 'flowroot' : 'flowRoot', # obsolete, do not use + 'flowpara' : 'flowPara', # obsolete, do not use + 'flowspan' : 'flowSpan', # obsolete, do not use + 'flowtref' : 'flowTref', # obsolete, do not use + 'foreignobject' : 'foreignObject', + 'glyphref' : 'glyphRef', + 'lineargradient' : 'linearGradient', + 'radialgradient' : 'radialGradient', + 'textpath' : 'textPath' + } + class QuickXHTMLParser(object): def __init__(self): @@ -93,7 +144,14 @@ def parsetag(self, s): tattr['special'] = s[p:backstep] return tname, ttype, tattr while p < n and s[p:p + 1] not in ('>', '/', ' ', '"', "'", "\r", "\n") : p += 1 + # In xhtml tag name case matters especially for svg + # but in html they are not case senstive and lots of bad case html + # tags exist in the wild. + # try to deal with that by lowercasing all tag names + # and then fixing up the case senstive ones tname = s[b:p].lower() + if tname in SVG_TAG_NAME_FIXUPS: + tname = SVG_TAG_NAME_FIXUPS[tname] # deal with other remaining special cases # generic xml processing instruction (pi) if tname != "?xml" and s[b:b+1] == "?": diff --git a/src/Resource_Files/plugin_launchers/python/wrapper.py b/src/Resource_Files/plugin_launchers/python/wrapper.py index 9491f85404..b3f2ef0918 100644 --- a/src/Resource_Files/plugin_launchers/python/wrapper.py +++ b/src/Resource_Files/plugin_launchers/python/wrapper.py @@ -49,7 +49,7 @@ def _unicodestr(p): return p return p.decode('utf-8', errors='replace') -_launcher_version = 20231026 +_launcher_version = 20231214 _PKG_VER = re.compile(r'''<\s*package[^>]*version\s*=\s*["']([^'"]*)['"][^>]*>''', re.IGNORECASE)