Skip to content

Commit fc2cd53

Browse files
committed
Make mistune.util.escape_url less aggressive
This adds ';', '!', and '$' to the set of characters which will be passed unmolested by escape_url. These are all in RFC 3986 reserved character list — that is to say: escaping these may change the meaning of a URL.
1 parent 3e8d352 commit fc2cd53

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

mistune/util.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ def escape(s, quote=True):
2020

2121

2222
def escape_url(link):
23-
safe = '/#:()*?=%@+,&'
23+
safe = (
24+
':/?#@' # gen-delims - '[]' (rfc3986)
25+
'!$&()*+,;=' # sub-delims - "'" (rfc3986)
26+
'%' # leave already-encoded octets alone
27+
)
28+
2429
if html is None:
2530
return quote(link.encode('utf-8'), safe=safe)
2631
return html.escape(quote(html.unescape(link), safe=safe))

0 commit comments

Comments
 (0)