@@ -3185,6 +3185,7 @@ def sha256dda(nodehelloid, identifier, path=None):
3185
3185
tohash = b"-" .join ([nodehelloid .encode ('utf-8' ), identifier .encode ('utf-8' ), open (path , "rb" ).read ()])
3186
3186
return hashlib .sha256 (tohash ).digest ()
3187
3187
3188
+
3188
3189
def guessMimetype (filename ):
3189
3190
"""
3190
3191
Returns a guess of a mimetype based on a filename's extension
@@ -3197,20 +3198,22 @@ def guessMimetype(filename):
3197
3198
return ('application/x-tar' , 'bzip2' )
3198
3199
try :
3199
3200
m = mimetypes .guess_type (filename , False )[0 ]
3200
- except TypeError : # bytes compared to string string …
3201
+ except TypeError : # bytes compared to string string …
3201
3202
try :
3202
3203
m = mimetypes .guess_type (filename .decode (), False )[0 ]
3203
- except :
3204
+ except Exception :
3204
3205
m = None
3205
- except :
3206
+ except Exception :
3206
3207
m = None
3207
- if m == "audio/mpegurl" : # disallowed mime type by FF
3208
+ if m == "audio/mpegurl" : # disallowed mime type by FF
3208
3209
m = "audio/x-mpegurl"
3209
- if m is None : # either an exception or a genuine None
3210
- # FIXME: log(INFO, "Could not find mimetype for filename %s" % filename)
3210
+ if m is None : # either an exception or a genuine None
3211
+ # FIXME: log(INFO,
3212
+ # "Could not find mimetype for filename %s" % filename)
3211
3213
m = "application/octet-stream"
3212
3214
return m
3213
3215
3216
+
3214
3217
_re_slugify = re .compile ('[^\w\s\.-]' , re .UNICODE )
3215
3218
_re_slugify_multidashes = re .compile ('[-\s]+' , re .UNICODE )
3216
3219
def toUrlsafe (filename ):
0 commit comments