Skip to content

Commit

Permalink
Merge pull request #22646 from nextcloud/bugfix/mimetype-mapping
Browse files Browse the repository at this point in the history
Fix detecting text/x-php mimetype and secure mimetype mapping
  • Loading branch information
rullzer authored Sep 8, 2020
2 parents b4729ce + 16b9817 commit 919a8d4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion lib/private/Files/Type/Detection.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,14 @@ public function registerTypeArray(array $types): void {
$this->mimetypes = array_merge($this->mimetypes, $types);

// Update the alternative mimetypes to avoid having to look them up each time.
foreach ($this->mimetypes as $mimeType) {
foreach ($this->mimetypes as $extension => $mimeType) {
if (strpos($extension, '_comment') === 0) {
continue;
}
$this->secureMimeTypes[$mimeType[0]] = $mimeType[1] ?? $mimeType[0];
if (isset($mimeType[1])) {
$this->secureMimeTypes[$mimeType[1]] = $mimeType[1];
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion resources/config/mimetypemapping.dist.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
"pdf": ["application/pdf"],
"pfb": ["application/x-font"],
"pef": ["image/x-dcraw"],
"php": ["application/x-php"],
"php": ["application/x-php", "text/x-php"],
"pl": ["application/x-perl"],
"pls": ["audio/x-scpls"],
"png": ["image/png"],
Expand Down

0 comments on commit 919a8d4

Please sign in to comment.