|
@@ -27,22 +27,25 @@ class FortuneHTMLParser(HTMLParser):
|
|
# """ is a valid escaping, but we are normalizing
|
|
# """ is a valid escaping, but we are normalizing
|
|
# it so that our final parse can just be checked for
|
|
# it so that our final parse can just be checked for
|
|
# equality.
|
|
# equality.
|
|
- norm = name.replace("34", "quot")
|
|
|
|
|
|
+ if name == "34":
|
|
|
|
+ # Append our normalized entity reference to our body.
|
|
|
|
+ self.body.append(""")
|
|
# Again, "+" is a valid escaping of the "+", but
|
|
# Again, "+" is a valid escaping of the "+", but
|
|
# it is not required, so we need to normalize for out
|
|
# it is not required, so we need to normalize for out
|
|
# final parse and equality check.
|
|
# final parse and equality check.
|
|
- norm = norm.replace("43", "+")
|
|
|
|
|
|
+ if name == "43":
|
|
|
|
+ self.body.append("+")
|
|
# Again, ">" is a valid escaping of ">", but we
|
|
# Again, ">" is a valid escaping of ">", but we
|
|
# need to normalize to ">" for equality checking.
|
|
# need to normalize to ">" for equality checking.
|
|
- norm = norm.replace("62", "gt")
|
|
|
|
|
|
+ if name == "62":
|
|
|
|
+ self.body.append(">")
|
|
# Again, "<" is a valid escaping of "<", but we
|
|
# Again, "<" is a valid escaping of "<", but we
|
|
# need to nromalize to "<" for equality checking.
|
|
# need to nromalize to "<" for equality checking.
|
|
- norm = norm.replace("60", "lt")
|
|
|
|
- # Append our normalized entity reference to our body.
|
|
|
|
- self.body.append("&{n};".format(n=norm))
|
|
|
|
|
|
+ if name == "60":
|
|
|
|
+ self.body.append("<")
|
|
|
|
|
|
def handle_entityref(self, name):
|
|
def handle_entityref(self, name):
|
|
- self.body.append("&{n};".format(n=norm))
|
|
|
|
|
|
+ self.body.append("&{n};".format(n=name))
|
|
|
|
|
|
# This is called every time a tag is opened. We append
|
|
# This is called every time a tag is opened. We append
|
|
# each one wrapped in "<" and ">".
|
|
# each one wrapped in "<" and ">".
|