javascript urls are less quoted for compatibility

git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@1532 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
calvin 2004-08-27 12:03:49 +00:00
parent 3d678d6d3b
commit 09adff7cf6
2 changed files with 9 additions and 1 deletions

View file

@ -246,6 +246,10 @@ class TestUrl (unittest.TestCase):
url = "news:§$%&/´`(§%"
nurl = 'news:%A7%24%25%26/%B4%60%28%A7%25'
self.assertEqual(linkcheck.url.url_norm(url), nurl)
# javascript url
url = "javascript:loadthis()"
nurl = url
self.assertEqual(linkcheck.url.url_norm(url), nurl)
def test_norm_with_auth (self):
"""test norming of urls with authentication tokens"""

View file

@ -192,7 +192,11 @@ def url_norm (url):
# quote parts again
urlparts[0] = urllib.quote(urlparts[0]) # scheme
urlparts[1] = urllib.quote(urlparts[1], ':@') # host
urlparts[2] = urllib.quote(urlparts[2], '/=,~') # path
nopathquote = ';/=,~'
# note: the list of chars not to quote is different for javascript urls
if urlparts[0]=='javascript':
nopathquote += '()+-'
urlparts[2] = urllib.quote(urlparts[2], nopathquote) # path
res = urlparse.urlunsplit(urlparts)
if url.endswith('#') and not urlparts[4]:
# append trailing empty fragment