mirror of https://github.com/zulip/zulip.git
Allow domain-relative and fragment links
(imported from commit 0a15eeb35ad709977f3b2e6c550c3b78f1b4b402)
This commit is contained in:
parent
f4323a6c51
commit
e3b2e7ece2
|
@ -397,9 +397,14 @@ def sanitize_url(url):
|
|||
# treat it as a mailto: and set the appropriate scheme
|
||||
if scheme == '' and netloc == '' and '@' in path:
|
||||
scheme = 'mailto'
|
||||
elif scheme == '' and netloc == '' and len(path) > 0 and path[0] == '/':
|
||||
# Allow domain-relative links
|
||||
return urlparse.urlunparse(('', '', path, params, query, fragment))
|
||||
elif (scheme, netloc, path, params, query) == ('', '', '', '', '') and len(fragment) > 0:
|
||||
# Allow fragment links
|
||||
return urlparse.urlunparse(('', '', '', '', '', fragment))
|
||||
|
||||
# Zulip modification: If scheme is not specified, assume http://
|
||||
# It's unlikely that users want relative links within zulip.com.
|
||||
# We re-enter sanitize_url because netloc etc. need to be re-parsed.
|
||||
if not scheme:
|
||||
return sanitize_url('http://' + url)
|
||||
|
|
Loading…
Reference in New Issue