@@ -614,32 +614,40 @@ def test_urlsplit_attributes(self):
614614
615615 def test_urlsplit_remove_unsafe_bytes (self ):
616616 # Remove ASCII tabs and newlines from input
617- url = "http://www.python.org/java\n script:\t alert('msg\r \n ')/#frag"
617+ url = "http\t ://www.python\n .org\t /java\n script:\t alert('msg\r \n ')/?query \n = \t something #frag\n ment "
618618 p = urllib .parse .urlsplit (url )
619619 self .assertEqual (p .scheme , "http" )
620620 self .assertEqual (p .netloc , "www.python.org" )
621621 self .assertEqual (p .path , "/javascript:alert('msg')/" )
622- self .assertEqual (p .query , "" )
623- self .assertEqual (p .fragment , "frag " )
622+ self .assertEqual (p .query , "query=something " )
623+ self .assertEqual (p .fragment , "fragment " )
624624 self .assertEqual (p .username , None )
625625 self .assertEqual (p .password , None )
626626 self .assertEqual (p .hostname , "www.python.org" )
627627 self .assertEqual (p .port , None )
628- self .assertEqual (p .geturl (), "http://www.python.org/javascript:alert('msg')/#frag " )
628+ self .assertEqual (p .geturl (), "http://www.python.org/javascript:alert('msg')/?query=something#fragment " )
629629
630630 # Remove ASCII tabs and newlines from input as bytes.
631- url = b"http://www.python.org/java\n script:\t alert('msg\r \n ')/#frag"
631+ url = b"http\t ://www.python\n .org\t /java\n script:\t alert('msg\r \n ')/?query \n = \t something #frag\n ment "
632632 p = urllib .parse .urlsplit (url )
633633 self .assertEqual (p .scheme , b"http" )
634634 self .assertEqual (p .netloc , b"www.python.org" )
635635 self .assertEqual (p .path , b"/javascript:alert('msg')/" )
636- self .assertEqual (p .query , b"" )
637- self .assertEqual (p .fragment , b"frag " )
636+ self .assertEqual (p .query , b"query=something " )
637+ self .assertEqual (p .fragment , b"fragment " )
638638 self .assertEqual (p .username , None )
639639 self .assertEqual (p .password , None )
640640 self .assertEqual (p .hostname , b"www.python.org" )
641641 self .assertEqual (p .port , None )
642- self .assertEqual (p .geturl (), b"http://www.python.org/javascript:alert('msg')/#frag" )
642+ self .assertEqual (p .geturl (), b"http://www.python.org/javascript:alert('msg')/?query=something#fragment" )
643+
644+ # with scheme as cache-key
645+ url = "http://www.python.org/java\n script:\t alert('msg\r \n ')/?query\n =\t something#frag\n ment"
646+ scheme = "ht\n tp"
647+ for _ in range (2 ):
648+ p = urllib .parse .urlsplit (url , scheme = scheme )
649+ self .assertEqual (p .scheme , "http" )
650+ self .assertEqual (p .geturl (), "http://www.python.org/javascript:alert('msg')/?query=something#fragment" )
643651
644652 def test_attributes_bad_port (self ):
645653 """Check handling of invalid ports."""
0 commit comments