Skip to content

Commit

Permalink
Merge pull request #295 from dairiki/bug.escape_url
Browse files Browse the repository at this point in the history
Mistune.util.escape_url is too aggressive
  • Loading branch information
lepture authored Jan 14, 2022
2 parents 3e8d352 + fc2cd53 commit babb0cf
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion mistune/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ def escape(s, quote=True):


def escape_url(link):
safe = '/#:()*?=%@+,&'
safe = (
':/?#@' # gen-delims - '[]' (rfc3986)
'!$&()*+,;=' # sub-delims - "'" (rfc3986)
'%' # leave already-encoded octets alone
)

if html is None:
return quote(link.encode('utf-8'), safe=safe)
return html.escape(quote(html.unescape(link), safe=safe))
Expand Down

0 comments on commit babb0cf

Please sign in to comment.