From b514575d5fb99b20e826009213605c2840ee6b07 Mon Sep 17 00:00:00 2001 From: Leonard Richardson Date: Sun, 30 Dec 2018 21:13:03 -0500 Subject: Fixed a problem with multi-valued attributes where the value contained whitespace. Thanks to Jens Svalgaard for the fix. [bug=1787453] --- bs4/testing.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'bs4/testing.py') diff --git a/bs4/testing.py b/bs4/testing.py index 9598f31..e4a0ffe 100644 --- a/bs4/testing.py +++ b/bs4/testing.py @@ -452,6 +452,18 @@ Hello, world! "Bar" "Baz") + def test_multivalued_attribute_with_whitespace(self): + # Whitespace separating the values of a multi-valued attribute + # should be ignored. + + markup = '
' + soup = self.soup(markup) + self.assertEqual(['foo', 'bar'], soup.div['class']) + + # If you search by the literal name of the class it's like the whitespace + # wasn't there. + self.assertEqual(soup.div, soup.find('div', class_="foo bar")) + def test_deeply_nested_multivalued_attribute(self): # html5lib can set the attributes of the same tag many times # as it rearranges the tree. This has caused problems with -- cgit v1.2.3