[GMG-Devel] [PATCH] mediagoblin/media_types/__init__.py: fix off by one error

Alon Levy alon at pobox.com
Tue Feb 25 08:31:17 EST 2014


get_media_type_and_manager was not correctly getting the extention for files
starting with a ".". string.find returns -1 on error, not 0 - 0 is a valid
index.
---
 mediagoblin/media_types/__init__.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mediagoblin/media_types/__init__.py b/mediagoblin/media_types/__init__.py
index 2e39231..6b02900 100644
--- a/mediagoblin/media_types/__init__.py
+++ b/mediagoblin/media_types/__init__.py
@@ -85,7 +85,7 @@ def get_media_type_and_manager(filename):
     specifically. This is used as a speedup, the sniffing functionality
     then falls back on more in-depth bitsniffing of the source file.
     '''
-    if filename.find('.') > 0:
+    if filename.find('.') > -1:
         # Get the file extension
         ext = os.path.splitext(filename)[1].lower()
 
-- 
1.8.5.3



More information about the devel mailing list