1. Mikhail Korobov
  2. WebTest

Commits

Mikhail Korobov  committed 7d53e8c

Corrected parsing of single-quoted attributes

  • Participants
  • Parent commits 4ad3130
  • Branches default

Comments (0)

Files changed (2)

File tests/test_click.py

View file
+from webtest import _parse_attrs
+
+def test_parse_attrs():
+    assert _parse_attrs("href='foo'") == {'href': 'foo'}
+    assert _parse_attrs('href="foo"') == {'href': 'foo'}
+    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'}

File webtest/__init__.py

View file
         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 = {}