mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-24 03:33:11 +01:00
Web: Ignore SVG titles. Closes GH-1147.
This commit is contained in:
parent
576a96fb71
commit
20ef13ef9f
@ -56,28 +56,37 @@ class Title(HTMLParser):
|
||||
entitydefs['apos'] = '\''
|
||||
def __init__(self):
|
||||
self.inTitle = False
|
||||
self.inSvg = False
|
||||
self.title = ''
|
||||
HTMLParser.__init__(self)
|
||||
|
||||
@property
|
||||
def inHtmlTitle(self):
|
||||
return self.inTitle and not self.inSvg
|
||||
|
||||
def handle_starttag(self, tag, attrs):
|
||||
if tag == 'title':
|
||||
self.inTitle = True
|
||||
elif tag == 'svg':
|
||||
self.inSvg = True
|
||||
|
||||
def handle_endtag(self, tag):
|
||||
if tag == 'title':
|
||||
self.inTitle = False
|
||||
elif tag == 'svg':
|
||||
self.inSvg = False
|
||||
|
||||
def handle_data(self, data):
|
||||
if self.inTitle:
|
||||
if self.inHtmlTitle:
|
||||
self.title += data
|
||||
|
||||
def handle_entityref(self, name):
|
||||
if self.inTitle:
|
||||
if self.inHtmlTitle:
|
||||
if name in self.entitydefs:
|
||||
self.title += self.entitydefs[name]
|
||||
|
||||
def handle_charref(self, name):
|
||||
if self.inTitle:
|
||||
if self.inHtmlTitle:
|
||||
self.title += (unichr if minisix.PY2 else chr)(int(name))
|
||||
|
||||
class DelayedIrc:
|
||||
|
Loading…
Reference in New Issue
Block a user