Skip to content

Commit

Permalink
update python quickparser to more properly handle mixed case svg tag …
Browse files Browse the repository at this point in the history
…names
  • Loading branch information
kevinhendricks committed Dec 14, 2023
1 parent 1b1ea15 commit 1968510
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 1 deletion.
58 changes: 58 additions & 0 deletions src/Resource_Files/plugin_launchers/python/quickparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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] == "?":
Expand Down
2 changes: 1 addition & 1 deletion src/Resource_Files/plugin_launchers/python/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 1968510

Please sign in to comment.