@@ -3185,6 +3185,7 @@ def sha256dda(nodehelloid, identifier, path=None):
31853185 tohash = b"-" .join ([nodehelloid .encode ('utf-8' ), identifier .encode ('utf-8' ), open (path , "rb" ).read ()])
31863186 return hashlib .sha256 (tohash ).digest ()
31873187
3188+
31883189def guessMimetype (filename ):
31893190 """
31903191 Returns a guess of a mimetype based on a filename's extension
@@ -3197,20 +3198,22 @@ def guessMimetype(filename):
31973198 return ('application/x-tar' , 'bzip2' )
31983199 try :
31993200 m = mimetypes .guess_type (filename , False )[0 ]
3200- except TypeError : # bytes compared to string string …
3201+ except TypeError : # bytes compared to string string …
32013202 try :
32023203 m = mimetypes .guess_type (filename .decode (), False )[0 ]
3203- except :
3204+ except Exception :
32043205 m = None
3205- except :
3206+ except Exception :
32063207 m = None
3207- if m == "audio/mpegurl" : # disallowed mime type by FF
3208+ if m == "audio/mpegurl" : # disallowed mime type by FF
32083209 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)
32113213 m = "application/octet-stream"
32123214 return m
32133215
3216+
32143217_re_slugify = re .compile ('[^\w\s\.-]' , re .UNICODE )
32153218_re_slugify_multidashes = re .compile ('[-\s]+' , re .UNICODE )
32163219def toUrlsafe (filename ):
0 commit comments