[formatter] exclude '<>\' from '!R' URLs (#8180)
This commit is contained in:
@@ -565,7 +565,7 @@ _CONVERSIONS = {
|
|||||||
"U": text.unescape,
|
"U": text.unescape,
|
||||||
"H": lambda s: text.unescape(text.remove_html(s)),
|
"H": lambda s: text.unescape(text.remove_html(s)),
|
||||||
"g": text.slugify,
|
"g": text.slugify,
|
||||||
"R": text.re(r"https?://[^\s\"']+").findall,
|
"R": text.re(r"https?://[^\s\"'<>\\]+").findall,
|
||||||
"W": text.sanitize_whitespace,
|
"W": text.sanitize_whitespace,
|
||||||
"S": util.to_string,
|
"S": util.to_string,
|
||||||
"s": str,
|
"s": str,
|
||||||
|
|||||||
@@ -46,7 +46,8 @@ class TestFormatter(unittest.TestCase):
|
|||||||
"h": "<p>foo </p> & bar <p> </p>",
|
"h": "<p>foo </p> & bar <p> </p>",
|
||||||
"H": """<p>
|
"H": """<p>
|
||||||
<a href="http://www.example.com">Lorem ipsum dolor sit amet</a>.
|
<a href="http://www.example.com">Lorem ipsum dolor sit amet</a>.
|
||||||
Duis aute irure <a href="http://blog.example.org">dolor</a>.
|
Duis aute irure <a href="http://blog.example.org/lorem?foo=bar">
|
||||||
|
http://blog.example.org</a>.
|
||||||
</p>""",
|
</p>""",
|
||||||
"u": "'< / >'",
|
"u": "'< / >'",
|
||||||
"t": 1262304000,
|
"t": 1262304000,
|
||||||
@@ -78,6 +79,7 @@ class TestFormatter(unittest.TestCase):
|
|||||||
self._run_test("{n!H}", "")
|
self._run_test("{n!H}", "")
|
||||||
self._run_test("{h!R}", [])
|
self._run_test("{h!R}", [])
|
||||||
self._run_test("{H!R}", ["http://www.example.com",
|
self._run_test("{H!R}", ["http://www.example.com",
|
||||||
|
"http://blog.example.org/lorem?foo=bar",
|
||||||
"http://blog.example.org"])
|
"http://blog.example.org"])
|
||||||
self._run_test("{a!s}", self.kwdict["a"])
|
self._run_test("{a!s}", self.kwdict["a"])
|
||||||
self._run_test("{a!r}", f"'{self.kwdict['a']}'")
|
self._run_test("{a!r}", f"'{self.kwdict['a']}'")
|
||||||
|
|||||||
Reference in New Issue
Block a user