mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-25 04:02:46 +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'] = '\''
|
entitydefs['apos'] = '\''
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.inTitle = False
|
self.inTitle = False
|
||||||
|
self.inSvg = False
|
||||||
self.title = ''
|
self.title = ''
|
||||||
HTMLParser.__init__(self)
|
HTMLParser.__init__(self)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def inHtmlTitle(self):
|
||||||
|
return self.inTitle and not self.inSvg
|
||||||
|
|
||||||
def handle_starttag(self, tag, attrs):
|
def handle_starttag(self, tag, attrs):
|
||||||
if tag == 'title':
|
if tag == 'title':
|
||||||
self.inTitle = True
|
self.inTitle = True
|
||||||
|
elif tag == 'svg':
|
||||||
|
self.inSvg = True
|
||||||
|
|
||||||
def handle_endtag(self, tag):
|
def handle_endtag(self, tag):
|
||||||
if tag == 'title':
|
if tag == 'title':
|
||||||
self.inTitle = False
|
self.inTitle = False
|
||||||
|
elif tag == 'svg':
|
||||||
|
self.inSvg = False
|
||||||
|
|
||||||
def handle_data(self, data):
|
def handle_data(self, data):
|
||||||
if self.inTitle:
|
if self.inHtmlTitle:
|
||||||
self.title += data
|
self.title += data
|
||||||
|
|
||||||
def handle_entityref(self, name):
|
def handle_entityref(self, name):
|
||||||
if self.inTitle:
|
if self.inHtmlTitle:
|
||||||
if name in self.entitydefs:
|
if name in self.entitydefs:
|
||||||
self.title += self.entitydefs[name]
|
self.title += self.entitydefs[name]
|
||||||
|
|
||||||
def handle_charref(self, name):
|
def handle_charref(self, name):
|
||||||
if self.inTitle:
|
if self.inHtmlTitle:
|
||||||
self.title += (unichr if minisix.PY2 else chr)(int(name))
|
self.title += (unichr if minisix.PY2 else chr)(int(name))
|
||||||
|
|
||||||
class DelayedIrc:
|
class DelayedIrc:
|
||||||
|
Loading…
Reference in New Issue
Block a user