[3.8] bpo-38449: Revert "bpo-22347: Update mimetypes.guess_type to al… · python/cpython@5a638a8 (original) (raw)
Navigation Menu
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Appearance settings
Commit 5a638a8
File tree
4 files changed
lines changed
4 files changed
lines changed
Lines changed: 1 addition & 2 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -114,8 +114,7 @@ def guess_type(self, url, strict=True): | ||
| 114 | 114 | but non-standard types. |
| 115 | 115 | """ |
| 116 | 116 | url = os.fspath(url) |
| 117 | -p = urllib.parse.urlparse(url) | |
| 118 | -scheme, url = p.scheme, p.path | |
| 117 | +scheme, url = urllib.parse._splittype(url) | |
| 119 | 118 | if scheme == 'data': |
| 120 | 119 | # syntax of data URLs: |
| 121 | 120 | # dataurl := "data:" [ mediatype ] [ ";base64" ] "," data |
Lines changed: 0 additions & 8 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -51,14 +51,6 @@ 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_url(self): | |
| 55 | -result = self.db.guess_type('http://host.html') | |
| 56 | -msg = 'URL only has a host name, not a file' | |
| 57 | -self.assertSequenceEqual(result, (None, None), msg) | |
| 58 | -result = self.db.guess_type('http://example.com/host.html') | |
| 59 | -msg = 'Should be text/html' | |
| 60 | -self.assertSequenceEqual(result, ('text/html', None), msg) | |
| 61 | - | |
| 62 | 54 | def test_guess_all_types(self): |
| 63 | 55 | eq = self.assertEqual |
| 64 | 56 | unless = self.assertTrue |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -744,7 +744,7 @@ def connect_ftp(self, user, passwd, host, port, dirs, | ||
| 744 | 744 | ["foo", "bar"], "", None), |
| 745 | 745 | ("ftp://localhost/baz.gif;type=a", |
| 746 | 746 | "localhost", ftplib.FTP_PORT, "", "", "A", |
| 747 | - [], "baz.gif", "image/gif"), | |
| 747 | + [], "baz.gif", None), # XXX really this should guess image/gif | |
| 748 | 748 | ]: |
| 749 | 749 | req = Request(url) |
| 750 | 750 | req.timeout = None |
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| 1 | +Revert GH-15522, which introduces a regression in | |
| 2 | +:meth:`mimetypes.guess_type` due to improper handling of filenames as urls. |