From 98c5487d63014b6c57487530d21240dde73973f5 Mon Sep 17 00:00:00 2001 From: maksis Date: Tue, 26 Jan 2016 18:19:01 +0200 Subject: [PATCH] Squashed 'airdcpp-webapi/' changes from 906cc41..304979f 304979f Fix a possible crash when viewing files git-subtree-dir: airdcpp-webapi git-subtree-split: 304979f0a5572532a6ec0f945d07156a31f6253c --- api/ViewFileApi.cpp | 3 ++- web-server/FileServer.cpp | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/api/ViewFileApi.cpp b/api/ViewFileApi.cpp index c0730ae4..f7bf3a50 100644 --- a/api/ViewFileApi.cpp +++ b/api/ViewFileApi.cpp @@ -53,6 +53,7 @@ namespace webserver { } json ViewFileApi::serializeFile(const ViewFilePtr& aFile) noexcept { + auto mimeType = FileServer::getMimeType(aFile->getPath()); return{ { "id", aFile->getTTH().toBase32() }, { "tth", aFile->getTTH().toBase32() }, @@ -63,7 +64,7 @@ namespace webserver { { "type", Serializer::serializeFileType(aFile->getPath()) }, { "time_finished", aFile->getTimeFinished() }, { "downloaded", !aFile->isLocalFile() }, - { "mime_type", FileServer::getMimeType(aFile->getPath()) }, + { "mime_type", mimeType ? mimeType : Util::emptyString }, }; } diff --git a/web-server/FileServer.cpp b/web-server/FileServer.cpp index c4256005..ce789278 100644 --- a/web-server/FileServer.cpp +++ b/web-server/FileServer.cpp @@ -110,6 +110,7 @@ namespace webserver { { "bat", "text/plain" }, { "vb", "text/plain" }, { "cs", "text/plain" }, + { "nfo", "text/x-nfo" }, { "pl", "text/plain" }, { "py", "text/plain" }, { "class", "text/plain" },