File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,21 @@ def test_non_standard_types(self):
50
50
eq (self .db .guess_type ('foo.xul' , strict = False ), ('text/xul' , None ))
51
51
eq (self .db .guess_extension ('image/jpg' , strict = False ), '.jpg' )
52
52
53
+ def test_filename_with_url_delimiters (self ):
54
+ # bpo-38449: URL delimiters cases should be handled also.
55
+ # They would have different mime types if interpreted as URL as
56
+ # compared to when interpreted as filename because of the semicolon.
57
+ eq = self .assertEqual
58
+ gzip_expected = ('application/x-tar' , 'gzip' )
59
+ eq (self .db .guess_type (";1.tar.gz" ), gzip_expected )
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=123;?.tar.gz" ), gzip_expected )
65
+ eq (self .db .guess_type ("?k1=v1&k2=v2.tar.gz" ), gzip_expected )
66
+ eq (self .db .guess_type (r" \"\`;b&b&c |.tar.gz" ), gzip_expected )
67
+
53
68
def test_guess_all_types (self ):
54
69
eq = self .assertEqual
55
70
unless = self .assertTrue
You can’t perform that action at this time.
0 commit comments