Commits

Mikhail Korobov committed 54d5ead

Correct handling of single quote inside double quote and vice versa

Comments (0)

Files changed (2)

tests/test_click.py

     assert 'This is baz.' in resp.click(anchor=u".*title='Поэт'.*")
 
 
-
 def test_parse_attrs():
     assert _parse_attrs("href='foo'") == {'href': 'foo'}
     assert _parse_attrs('href="foo"') == {'href': 'foo'}
+    assert _parse_attrs('href=""') == {'href': ''}
     assert _parse_attrs('href="foo" id="bar"') == {'href': 'foo', 'id': 'bar'}
     assert _parse_attrs('href="foo" id="bar"') == {'href': 'foo', 'id': 'bar'}
     assert _parse_attrs("href='foo' id=\"bar\" ") == {'href': 'foo', 'id': 'bar'}
     assert _parse_attrs("href='foo' id='bar' ") == {'href': 'foo', 'id': 'bar'}
+    assert _parse_attrs("tag='foo\"'") == {'tag': 'foo"'}

webtest/__init__.py

         return submit
 
 
-_attr_re = re.compile(r'([^= \n\r\t]+)[ \n\r\t]*(?:=[ \n\r\t]*(?:["\']([^"\']*)["\']|([^"\'][^ \n\r\t>]*)))?', re.S)
+_attr_re = re.compile(r'([^= \n\r\t]+)[ \n\r\t]*(?:=[ \n\r\t]*(?:"([^"]*)"|\'([^\']*)\'|([^"][^ \n\r\t>]*)))?', re.S)
 
 def _parse_attrs(text):
     attrs = {}