HTMLParser is now able to handle slashes in the start tag.
This commit is contained in:
parent
9be6c3ddf0
commit
36b7361fe7
|
@ -28,19 +28,19 @@ tagfind = re.compile('[a-zA-Z][-.a-zA-Z0-9:_]*')
|
||||||
tagfind_tolerant = re.compile('[a-zA-Z][^\t\n\r\f />\x00]*')
|
tagfind_tolerant = re.compile('[a-zA-Z][^\t\n\r\f />\x00]*')
|
||||||
|
|
||||||
attrfind = re.compile(
|
attrfind = re.compile(
|
||||||
r'\s*((?<=[\'"\s])[^\s/>][^\s/=>]*)(\s*=+\s*'
|
r'[\s/]*((?<=[\'"\s/])[^\s/>][^\s/=>]*)(\s*=+\s*'
|
||||||
r'(\'[^\']*\'|"[^"]*"|(?![\'"])[^>\s]*))?')
|
r'(\'[^\']*\'|"[^"]*"|(?![\'"])[^>\s]*))?(?:\s|/(?!>))*')
|
||||||
|
|
||||||
locatestarttagend = re.compile(r"""
|
locatestarttagend = re.compile(r"""
|
||||||
<[a-zA-Z][-.a-zA-Z0-9:_]* # tag name
|
<[a-zA-Z][-.a-zA-Z0-9:_]* # tag name
|
||||||
(?:\s+ # whitespace before attribute name
|
(?:[\s/]* # optional whitespace before attribute name
|
||||||
(?:(?<=['"\s])[^\s/>][^\s/=>]* # attribute name
|
(?:(?<=['"\s/])[^\s/>][^\s/=>]* # attribute name
|
||||||
(?:\s*=+\s* # value indicator
|
(?:\s*=+\s* # value indicator
|
||||||
(?:'[^']*' # LITA-enclosed value
|
(?:'[^']*' # LITA-enclosed value
|
||||||
|"[^"]*" # LIT-enclosed value
|
|"[^"]*" # LIT-enclosed value
|
||||||
|(?!['"])[^>\s]* # bare value
|
|(?!['"])[^>\s]* # bare value
|
||||||
)
|
)
|
||||||
)?\s*
|
)?(?:\s|/(?!>))*
|
||||||
)*
|
)*
|
||||||
)?
|
)?
|
||||||
\s* # trailing whitespace
|
\s* # trailing whitespace
|
||||||
|
|
|
@ -240,6 +240,27 @@ text
|
||||||
self._run_check("<!DOCTYPE %s>" % dtd,
|
self._run_check("<!DOCTYPE %s>" % dtd,
|
||||||
[('decl', 'DOCTYPE ' + dtd)])
|
[('decl', 'DOCTYPE ' + dtd)])
|
||||||
|
|
||||||
|
def test_slashes_in_starttag(self):
|
||||||
|
self._run_check('<a foo="var"/>', [('startendtag', 'a', [('foo', 'var')])])
|
||||||
|
html = ('<img width=902 height=250px '
|
||||||
|
'src="/sites/default/files/images/homepage/foo.jpg" '
|
||||||
|
'/*what am I doing here*/ />')
|
||||||
|
expected = [(
|
||||||
|
'startendtag', 'img',
|
||||||
|
[('width', '902'), ('height', '250px'),
|
||||||
|
('src', '/sites/default/files/images/homepage/foo.jpg'),
|
||||||
|
('*what', None), ('am', None), ('i', None),
|
||||||
|
('doing', None), ('here*', None)]
|
||||||
|
)]
|
||||||
|
self._run_check(html, expected)
|
||||||
|
html = ('<a / /foo/ / /=/ / /bar/ / />'
|
||||||
|
'<a / /foo/ / /=/ / /bar/ / >')
|
||||||
|
expected = [
|
||||||
|
('startendtag', 'a', [('foo', None), ('=', None), ('bar', None)]),
|
||||||
|
('starttag', 'a', [('foo', None), ('=', None), ('bar', None)])
|
||||||
|
]
|
||||||
|
self._run_check(html, expected)
|
||||||
|
|
||||||
def test_declaration_junk_chars(self):
|
def test_declaration_junk_chars(self):
|
||||||
self._run_check("<!DOCTYPE foo $ >", [('decl', 'DOCTYPE foo $ ')])
|
self._run_check("<!DOCTYPE foo $ >", [('decl', 'DOCTYPE foo $ ')])
|
||||||
|
|
||||||
|
|
|
@ -98,6 +98,8 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- HTMLParser is now able to handle slashes in the start tag.
|
||||||
|
|
||||||
- Issue #14001: CVE-2012-0845: xmlrpc: Fix an endless loop in
|
- Issue #14001: CVE-2012-0845: xmlrpc: Fix an endless loop in
|
||||||
SimpleXMLRPCServer upon malformed POST request.
|
SimpleXMLRPCServer upon malformed POST request.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue