Attachments you submit will be routed for moderation. If you have an account, please
log in first.
|
File sugar-1241-base.patch, 1.2 KB
(added by alsroot, 4 years ago)
|
|
|
-
From 78ad10db61928ba53dc94a4ae51ce6c1d364bcef Mon Sep 17 00:00:00 2001
From: Aleksey Lim <alsroot@member.fsf.org>
Date: Wed, 2 Sep 2009 14:37:39 +0000
Subject: Readlink before checking mime type
---
src/sugar/mime.py | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/src/sugar/mime.py b/src/sugar/mime.py
index 8242dd4..45f1a9f 100644
|
a
|
b
|
|
| 90 | 90 | return types |
| 91 | 91 | |
| 92 | 92 | def get_for_file(file_name): |
| | 93 | if file_name.startswith('file://'): |
| | 94 | file_name = file_name[7:] |
| | 95 | |
| | 96 | if os.path.islink(file_name): |
| | 97 | symlink = os.readlink(file_name) |
| | 98 | if symlink.startswith('/'): |
| | 99 | file_name = symlink |
| | 100 | else: |
| | 101 | file_name = os.path.join(os.path.dirname(file_name), symlink) |
| | 102 | |
| 93 | 103 | mime_type = _sugarbaseext.get_mime_type_for_file(file_name) |
| 94 | 104 | if mime_type == 'application/octet-stream': |
| 95 | 105 | if _file_looks_like_text(file_name): |
| 96 | 106 | return 'text/plain' |
| 97 | 107 | else: |
| 98 | 108 | return 'application/octet-stream' |
| | 109 | |
| 99 | 110 | return mime_type |
| 100 | | |
| | 111 | |
| 101 | 112 | def get_from_file_name(file_name): |
| 102 | 113 | return _sugarbaseext.get_mime_type_from_file_name(file_name) |
| 103 | 114 | |
Download in other formats: