mirror of
https://github.com/python/cpython.git
synced 2025-10-17 20:28:43 +00:00
Allow "@" in unquoted attribute values.
Added test that checks for characters allowed in the query part of URLs. Backport candidate.
This commit is contained in:
parent
b616f17902
commit
75ab1462d5
2 changed files with 10 additions and 1 deletions
|
@ -33,7 +33,7 @@ endbracket = re.compile('[<>]')
|
||||||
tagfind = re.compile('[a-zA-Z][-_.a-zA-Z0-9]*')
|
tagfind = re.compile('[a-zA-Z][-_.a-zA-Z0-9]*')
|
||||||
attrfind = re.compile(
|
attrfind = re.compile(
|
||||||
r'\s*([a-zA-Z_][-:.a-zA-Z_0-9]*)(\s*=\s*'
|
r'\s*([a-zA-Z_][-:.a-zA-Z_0-9]*)(\s*=\s*'
|
||||||
r'(\'[^\']*\'|"[^"]*"|[-a-zA-Z0-9./,:;+*%?!&$\(\)_#=~\'"]*))?')
|
r'(\'[^\']*\'|"[^"]*"|[-a-zA-Z0-9./,:;+*%?!&$\(\)_#=~\'"@]*))?')
|
||||||
|
|
||||||
|
|
||||||
class SGMLParseError(RuntimeError):
|
class SGMLParseError(RuntimeError):
|
||||||
|
|
|
@ -200,6 +200,15 @@ DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01//EN'
|
||||||
self.check_events("""<a b='' c="">""", [
|
self.check_events("""<a b='' c="">""", [
|
||||||
("starttag", "a", [("b", ""), ("c", "")]),
|
("starttag", "a", [("b", ""), ("c", "")]),
|
||||||
])
|
])
|
||||||
|
# URL construction stuff from RFC 1808:
|
||||||
|
safe = "$-_.+"
|
||||||
|
extra = "!*'(),"
|
||||||
|
reserved = ";/?:@&="
|
||||||
|
url = "http://example.com:8080/path/to/file?%s%s%s" % (
|
||||||
|
safe, extra, reserved)
|
||||||
|
self.check_events("""<e a=%s>""" % url, [
|
||||||
|
("starttag", "e", [("a", url)]),
|
||||||
|
])
|
||||||
# Regression test for SF patch #669683.
|
# Regression test for SF patch #669683.
|
||||||
self.check_events("<e a=rgb(1,2,3)>", [
|
self.check_events("<e a=rgb(1,2,3)>", [
|
||||||
("starttag", "e", [("a", "rgb(1,2,3)")]),
|
("starttag", "e", [("a", "rgb(1,2,3)")]),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue