From 1e1f28658d6febdb5426379547c34c8248befdd8 Mon Sep 17 00:00:00 2001 From: andreimarcu Date: Fri, 22 Jul 2016 18:08:59 -0700 Subject: [PATCH] Remove spaces in mime mapping and ensure no spaces in filenames --- upload.go | 1 + util.go | 36 ++++++++++++++++++------------------ 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/upload.go b/upload.go index b8b395b..8c8f9f6 100644 --- a/upload.go +++ b/upload.go @@ -230,6 +230,7 @@ func processUpload(upReq UploadRequest) (upload Upload, err error) { } upload.Filename = strings.Join([]string{barename, extension}, ".") + upload.Filename = strings.Replace(upload.Filename, " ", "", -1) fileexists, _ := fileBackend.Exists(upload.Filename) diff --git a/util.go b/util.go index 37c59a9..c07a5f4 100644 --- a/util.go +++ b/util.go @@ -44,7 +44,7 @@ var mimeToExtension = map[string]string{ "application/gpx+xml": "gpx", "application/gxf": "gxf", "application/hyperstudio": "stk", - "application/inkml+xml": "ink inkml", + "application/inkml+xml": "ink", "application/ipfix": "ipfix", "application/java-archive": "jar", "application/java-serialized-object": "ser", @@ -135,7 +135,7 @@ var mimeToExtension = map[string]string{ "application/vnd.accpac.simply.aso": "aso", "application/vnd.accpac.simply.imp": "imp", "application/vnd.acucobol": "acu", - "application/vnd.acucorp": "atc acutc", + "application/vnd.acucorp": "atc", "application/vnd.adobe.air-application-installer-package+zip": "air", "application/vnd.adobe.formscentral.fcdt": "fcdt", "application/vnd.adobe.fxp": "fxp", @@ -226,14 +226,14 @@ var mimeToExtension = map[string]string{ "application/vnd.genomatix.tuxedo": "txd", "application/vnd.geogebra.file": "ggb", "application/vnd.geogebra.tool": "ggt", - "application/vnd.geometry-explorer": "gex gre", + "application/vnd.geometry-explorer": "gex", "application/vnd.geonext": "gxt", "application/vnd.geoplan": "g2w", "application/vnd.geospace": "g3w", "application/vnd.gmx": "gmx", "application/vnd.google-earth.kml+xml": "kml", "application/vnd.google-earth.kmz": "kmz", - "application/vnd.grafeq": "gqf gqs", + "application/vnd.grafeq": "gqf", "application/vnd.groove-account": "gac", "application/vnd.groove-help": "ghf", "application/vnd.groove-identity-message": "gim", @@ -256,7 +256,7 @@ var mimeToExtension = map[string]string{ "application/vnd.ibm.modcap": "afp", "application/vnd.ibm.rights-management": "irm", "application/vnd.ibm.secure-container": "sc", - "application/vnd.iccprofile": "icc icm", + "application/vnd.iccprofile": "icc", "application/vnd.igloader": "igl", "application/vnd.immervision-ivp": "ivp", "application/vnd.immervision-ivu": "ivu", @@ -284,7 +284,7 @@ var mimeToExtension = map[string]string{ "application/vnd.kde.kword": "kwd", "application/vnd.kenameaapp": "htke", "application/vnd.kidspiration": "kia", - "application/vnd.kinar": "kne knp", + "application/vnd.kinar": "kne", "application/vnd.koan": "skp", "application/vnd.kodak-descriptor": "sse", "application/vnd.las.las+xml": "lasxml", @@ -330,13 +330,13 @@ var mimeToExtension = map[string]string{ "application/vnd.ms-officetheme": "thmx", "application/vnd.ms-pki.seccat": "cat", "application/vnd.ms-pki.stl": "stl", - "application/vnd.ms-powerpoint": "ppt pps pot", + "application/vnd.ms-powerpoint": "ppt", "application/vnd.ms-powerpoint.addin.macroenabled.12": "ppam", "application/vnd.ms-powerpoint.presentation.macroenabled.12": "pptm", "application/vnd.ms-powerpoint.slide.macroenabled.12": "sldm", "application/vnd.ms-powerpoint.slideshow.macroenabled.12": "ppsm", "application/vnd.ms-powerpoint.template.macroenabled.12": "potm", - "application/vnd.ms-project": "mpp mpt", + "application/vnd.ms-project": "mpp", "application/vnd.ms-word.document.macroenabled.12": "docm", "application/vnd.ms-word.template.macroenabled.12": "dotm", "application/vnd.ms-works": "wps", @@ -347,7 +347,7 @@ var mimeToExtension = map[string]string{ "application/vnd.muvee.style": "msty", "application/vnd.mynfc": "taglet", "application/vnd.neurolanguage.nlu": "nlu", - "application/vnd.nitf": "ntf nitf", + "application/vnd.nitf": "ntf", "application/vnd.noblenet-directory": "nnd", "application/vnd.noblenet-sealer": "nns", "application/vnd.noblenet-web": "nnw", @@ -389,7 +389,7 @@ var mimeToExtension = map[string]string{ "application/vnd.osgeo.mapguide.package": "mgp", "application/vnd.osgi.dp": "dp", "application/vnd.osgi.subsystem": "esa", - "application/vnd.palm": "pdb pqa oprc", + "application/vnd.palm": "pdb", "application/vnd.pawaafile": "paw", "application/vnd.pg.format": "str", "application/vnd.pg.osasli": "ei6", @@ -655,8 +655,8 @@ var mimeToExtension = map[string]string{ "image/png": "png", "image/prs.btif": "btif", "image/sgi": "sgi", - "image/svg+xml": "svg svgz", - "image/tiff": "tiff tif", + "image/svg+xml": "svg", + "image/tiff": "tiff", "image/vnd.adobe.photoshop": "psd", "image/vnd.dece.graphic": "uvi", "image/vnd.dvb.subtitle": "sub", @@ -691,7 +691,7 @@ var mimeToExtension = map[string]string{ "image/x-xbitmap": "xbm", "image/x-xpixmap": "xpm", "image/x-xwindowdump": "xwd", - "message/rfc822": "eml mime", + "message/rfc822": "eml", "model/iges": "igs", "model/mesh": "mesh", "model/vnd.collada+xml": "dae", @@ -700,12 +700,12 @@ var mimeToExtension = map[string]string{ "model/vnd.gtw": "gtw", "model/vnd.mts": "mts", "model/vnd.vtu": "vtu", - "model/vrml": "wrl vrml", + "model/vrml": "wrl", "model/x3d+binary": "x3db", "model/x3d+vrml": "x3dv", "model/x3d+xml": "x3d", "text/cache-manifest": "appcache", - "text/calendar": "ics ifb", + "text/calendar": "ics", "text/css": "css", "text/csv": "csv", "text/html": "html", @@ -713,7 +713,7 @@ var mimeToExtension = map[string]string{ "text/plain": "txt", "text/prs.lines.tag": "dsc", "text/richtext": "rtx", - "text/sgml": "sgml sgm", + "text/sgml": "sgml", "text/tab-separated-values": "tsv", "text/troff": "t", "text/turtle": "ttl", @@ -732,12 +732,12 @@ var mimeToExtension = map[string]string{ "text/vnd.sun.j2me.app-descriptor": "jad", "text/vnd.wap.wml": "wml", "text/vnd.wap.wmlscript": "wmls", - "text/x-asm": "s asm", + "text/x-asm": "s", "text/x-c": "c", "text/x-fortran": "f", "text/x-java-source": "java", "text/x-opml": "opml", - "text/x-pascal": "p pas", + "text/x-pascal": "p", "text/x-nfo": "nfo", "text/x-shellscript": "sh", "text/x-setext": "etx",