From b266f9deed058798d0739a30ca5326784f6ef365 Mon Sep 17 00:00:00 2001 From: lxsang Date: Sat, 15 Sep 2018 21:35:07 +0200 Subject: [PATCH] fix mime bug --- Makefile | 2 +- apps/assets/scripts/main.js | 2 +- mimes.json | 19 +++++++++++++++++++ os/libs/vfs.lua | 4 +++- 4 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 mimes.json diff --git a/Makefile b/Makefile index 3ff9df1..1bcf105 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ BUILDDIR = ./build projs = grs info blog apps -copyfiles = index.ls +copyfiles = index.ls mimes.json main: clean copy for f in $(projs); do make -C "$${f}" ; done diff --git a/apps/assets/scripts/main.js b/apps/assets/scripts/main.js index 1ee5ffa..f586ffc 100644 --- a/apps/assets/scripts/main.js +++ b/apps/assets/scripts/main.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.9.3 +// Generated by CoffeeScript 1.12.7 (function() { var APIManager, BaseObject, MarkOn, extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, diff --git a/mimes.json b/mimes.json new file mode 100644 index 0000000..afabf6e --- /dev/null +++ b/mimes.json @@ -0,0 +1,19 @@ +{ + "odt": { "mime": "application/vnd.oasis.opendocument.text", "binary": true }, + "viz": { + "mime": "text/vnd.graphviz", + "binary": false + }, + "py": { + "mime": "text/x-python", + "binary": false + }, + "coffee":{ + "mime": "text/vnd.coffeescript", + "binary": false + }, + "apj": { + "mime": "text/antos-project", + "binary": false + } +} \ No newline at end of file diff --git a/os/libs/vfs.lua b/os/libs/vfs.lua index 9b215a6..0693b9a 100644 --- a/os/libs/vfs.lua +++ b/os/libs/vfs.lua @@ -113,7 +113,7 @@ vfs.write = function(path,data) local uid = ulib.uid(SESSION.user) -- if data ~= "" then - local header = string.match(data, "^data%:%w+%/%w+;base64,") + local header = string.match(data, "^data%:[%w%.-]+%/[%w%.-]+;base64,") if header ~= nil then local b64data = string.gsub(data, header,"") local barr = std.b64decode(b64data) @@ -124,6 +124,8 @@ vfs.write = function(path,data) f:write(bytes.__tostring(barr)) f:close() end + else + return false, "Wrong data format" end else bytes.write(bytes.new(0),osfile)