@@ -51,11 +51,20 @@ def test_non_standard_types(self):
51
51
eq (self .db .guess_type ('foo.xul' , strict = False ), ('text/xul' , None ))
52
52
eq (self .db .guess_extension ('image/jpg' , strict = False ), '.jpg' )
53
53
54
- def test_tricky_cases (self ):
55
- # bpo-38449: Tricky cases should be handled also.
54
+ def test_filename_with_url_delimiters (self ):
55
+ # bpo-38449: URL delimiters cases should be handled also.
56
+ # They would have different mime types if interpreted as URL as
57
+ # compared to when interpreted as filename because of the semicolon.
56
58
eq = self .assertEqual
57
- eq (self .db .guess_type (";1.tar.gz" ), ('application/x-tar' , 'gzip' ))
58
- eq (self .db .guess_type (r" \"\`;b&b&c |.tar.gz" ), ('application/x-tar' , 'gzip' ))
59
+ gzip_expected = ('application/x-tar' , 'gzip' )
60
+ eq (self .db .guess_type (";1.tar.gz" ), gzip_expected )
61
+ eq (self .db .guess_type ("?1.tar.gz" ), gzip_expected )
62
+ eq (self .db .guess_type ("#1.tar.gz" ), gzip_expected )
63
+ eq (self .db .guess_type ("#1#.tar.gz" ), gzip_expected )
64
+ eq (self .db .guess_type (";1#.tar.gz" ), gzip_expected )
65
+ eq (self .db .guess_type (";&1=123;?.tar.gz" ), gzip_expected )
66
+ eq (self .db .guess_type ("?k1=v1&k2=v2.tar.gz" ), gzip_expected )
67
+ eq (self .db .guess_type (r" \"\`;b&b&c |.tar.gz" ), gzip_expected )
59
68
60
69
def test_guess_all_types (self ):
61
70
eq = self .assertEqual
0 commit comments