--- Lib/sgmllib.old.py 2005-10-28 20:07:40.000000000 +0000 +++ Lib/sgmllib.py 2006-03-31 16:25:58.000000000 +0000 @@ -269,9 +269,24 @@ attrname, rest, attrvalue = match.group(1, 2, 3) if not rest: attrvalue = attrname - elif attrvalue[:1] == '\'' == attrvalue[-1:] or \ - attrvalue[:1] == '"' == attrvalue[-1:]: - attrvalue = attrvalue[1:-1] + else: + if attrvalue[:1] == '\'' == attrvalue[-1:] or \ + attrvalue[:1] == '"' == attrvalue[-1:]: + attrvalue = attrvalue[1:-1] + l = 0 + new_attrvalue = '' + while l < len(attrvalue): + attrvalue_match = entityref.match(attrvalue, l) + if attrvalue_match and \ + attrvalue_match.group(1) in self.entitydefs: + new_attrvalue += self.entitydefs[attrvalue_match.group(1)] + l = attrvalue_match.end(0) + if attrvalue[attrvalue_match.end(0) - 1] != ';': + l -= 1 + else: + new_attrvalue += attrvalue[l] + l += 1 + attrvalue = new_attrvalue attrs.append((attrname.lower(), attrvalue)) k = match.end(0) if rawdata[j] == '>': --- Lib/test/test_sgmllib.old.py 2005-10-28 20:07:28.000000000 +0000 +++ Lib/test/test_sgmllib.py 2006-03-31 16:41:30.000000000 +0000 @@ -213,6 +213,11 @@ self.check_events("", [ ("starttag", "e", [("a", "rgb(1,2,3)")]), ]) + # substitute entities + self.check_events("""""", \ + [("starttag", "a", [("b", "<"), \ + ("c", "<>"), \ + ("d", "< ")]),]) def test_attr_funky_names(self): self.check_events("""""", [