diff options
author | Leonard Richardson <leonardr@segfault.org> | 2013-05-31 09:51:21 -0400 |
---|---|---|
committer | Leonard Richardson <leonardr@segfault.org> | 2013-05-31 09:51:21 -0400 |
commit | e76e977befcee041f203c539e0021e822c28a32e (patch) | |
tree | 9ed5073e9955dc0dca387ccd276d75ef643ec763 | |
parent | 40d0fcd877e58f2862025f5a39a8ab0861e12b8b (diff) |
The html.parser treebuilder can now handle numeric attributes in
text when the hexidecimal name of the attribute starts with a
capital X.
-rw-r--r-- | NEWS.txt | 4 | ||||
-rw-r--r-- | bs4/builder/_htmlparser.py | 2 | ||||
-rw-r--r-- | bs4/testing.py | 2 |
3 files changed, 8 insertions, 0 deletions
@@ -24,6 +24,10 @@ * html5lib now supports Python 3. Fixed some Python 2-specific code in the html5lib test suite. [bug=1181624] +* The html.parser treebuilder can now handle numeric attributes in + text when the hexidecimal name of the attribute starts with a + capital X. Patch by Tim Shirley. [bug=1186242] + = 4.2.0 (20130514) = * The Tag.select() method now supports a much wider variety of CSS diff --git a/bs4/builder/_htmlparser.py b/bs4/builder/_htmlparser.py index e34c9fa..65ee618 100644 --- a/bs4/builder/_htmlparser.py +++ b/bs4/builder/_htmlparser.py @@ -58,6 +58,8 @@ class BeautifulSoupHTMLParser(HTMLParser): # it's fixed. if name.startswith('x'): real_name = int(name.lstrip('x'), 16) + elif name.startswith('X'): + real_name = int(name.lstrip('X'), 16) else: real_name = int(name) diff --git a/bs4/testing.py b/bs4/testing.py index d8ff6b7..23b26f1 100644 --- a/bs4/testing.py +++ b/bs4/testing.py @@ -228,12 +228,14 @@ class HTMLTreeBuilderSmokeTest(object): expect = u'<p id="pi\N{LATIN SMALL LETTER N WITH TILDE}ata"></p>' self.assertSoupEquals('<p id="piñata"></p>', expect) self.assertSoupEquals('<p id="piñata"></p>', expect) + self.assertSoupEquals('<p id="piñata"></p>', expect) self.assertSoupEquals('<p id="piñata"></p>', expect) def test_entities_in_text_converted_to_unicode(self): expect = u'<p>pi\N{LATIN SMALL LETTER N WITH TILDE}ata</p>' self.assertSoupEquals("<p>piñata</p>", expect) self.assertSoupEquals("<p>piñata</p>", expect) + self.assertSoupEquals("<p>piñata</p>", expect) self.assertSoupEquals("<p>piñata</p>", expect) def test_quot_entity_converted_to_quotation_mark(self): |