File tree Expand file tree Collapse file tree 2 files changed +13
-12
lines changed
Expand file tree Collapse file tree 2 files changed +13
-12
lines changed Original file line number Diff line number Diff line change @@ -648,12 +648,13 @@ def test_urlsplit_normalization(self):
648648 urlparse .urlsplit (u'http://\u30d5 \u309a \ufe13 80' )
649649
650650 for scheme in [u"http" , u"https" , u"ftp" ]:
651- for c in denorm_chars :
652- url = u"{}://netloc{}false.netloc/path" .format (scheme , c )
653- if test_support .verbose :
654- print "Checking %r" % url
655- with self .assertRaises (ValueError ):
656- urlparse .urlsplit (url )
651+ for netloc in [u"netloc{}false.netloc" , u"n{}user@netloc" ]:
652+ for c in denorm_chars :
653+ url = u"{}://{}/path" .format (scheme , netloc .format (c ))
654+ if test_support .verbose :
655+ print "Checking %r" % url
656+ with self .assertRaises (ValueError ):
657+ urlparse .urlsplit (url )
657658
658659def test_main ():
659660 test_support .run_unittest (UrlParseTestCase )
Original file line number Diff line number Diff line change @@ -171,17 +171,17 @@ def _checknetloc(netloc):
171171 # looking for characters like \u2100 that expand to 'a/c'
172172 # IDNA uses NFKC equivalence, so normalize for this check
173173 import unicodedata
174- n = netloc .rpartition ( '@' )[ 2 ] # ignore anything to the left of '@'
175- n = n .replace (':' , '' ) # ignore characters already included
176- n = n .replace ('#' , '' ) # but not the surrounding text
177- n = n .replace ('?' , '' )
174+ n = netloc .replace ( u '@', u'' ) # ignore characters already included
175+ n = n .replace (u ':' , u '' ) # but not the surrounding text
176+ n = n .replace (u '#' , u '' )
177+ n = n .replace (u '?' , u '' )
178178 netloc2 = unicodedata .normalize ('NFKC' , n )
179179 if n == netloc2 :
180180 return
181181 for c in '/?#@:' :
182182 if c in netloc2 :
183- raise ValueError ("netloc '" + netloc + "' contains invalid " +
184- "characters under NFKC normalization" )
183+ raise ValueError (u "netloc '" + netloc + u "' contains invalid " +
184+ u "characters under NFKC normalization" )
185185
186186def urlsplit (url , scheme = '' , allow_fragments = True ):
187187 """Parse a URL into 5 components:
You can’t perform that action at this time.
0 commit comments