find a better mimetype by using file() and the extension

This commit is contained in:
Uwe Steinmann 2022-11-09 15:14:38 +01:00
parent 5438d95eb5
commit b9311ff1e7

View File

@ -663,14 +663,17 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server
$tmp = explode(';', $mimetype); $tmp = explode(';', $mimetype);
$mimetype = $tmp[0]; $mimetype = $tmp[0];
$lastDotIndex = strrpos($name, ".");
if($lastDotIndex === false) $fileType = ".";
else $fileType = substr($name, $lastDotIndex);
switch($mimetype) { switch($mimetype) {
case 'application/pdf'; case 'application/pdf':
$fileType = ".pdf"; $fileType = ".pdf";
break; break;
default: case 'text/plain':
$lastDotIndex = strrpos($name, "."); if($fileType == '.md')
if($lastDotIndex === false) $fileType = "."; $mimetype = 'text/markdown';
else $fileType = substr($name, $lastDotIndex); break;
} }
if($this->logger) if($this->logger)
$this->logger->log('PUT: file is of type '.$mimetype, PEAR_LOG_INFO); $this->logger->log('PUT: file is of type '.$mimetype, PEAR_LOG_INFO);
@ -698,7 +701,7 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server
unlink($tmpFile); unlink($tmpFile);
return "403 Forbidden"; return "403 Forbidden";
} else { } else {
/* Check if the new version iѕ identical to the current version. /* Check if the new version is identical to the current version.
* In that case just update the modification date * In that case just update the modification date
*/ */
$lc = $document->getLatestContent(); $lc = $document->getLatestContent();