Skip to content

Conversation

@nickvergessen
Copy link
Member

No description provided.

@rullzer
Copy link
Member

rullzer commented Dec 10, 2019

Needs a rebase

Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
@nickvergessen nickvergessen force-pushed the bugfix/noid/always-detect-mimetype-by-content-in-workflows branch from 5c90aca to 6ad7e75 Compare December 10, 2019 08:12
@rullzer
Copy link
Member

rullzer commented Dec 10, 2019

mmm CI does 💥

Signed-off-by: Joas Schilling <coding@schilljs.com>
@nickvergessen
Copy link
Member Author

  1. Test\Files\Type\DetectionTest::testDetectContent with data set Name the repository "server" #1 ('/data.tar.gz', 'application/x-gzip')
    --
    -'application/x-gzip'
    +'application/octet-stream'

Great, works locally. I guess some package is missing. Let's try if testing all the content detections helps. If not someone else needs to take over, as this needs to go into the maintenance releases this week.

@kesselb
Copy link
Collaborator

kesselb commented Dec 10, 2019

file -i tests/data/data.tar.gz 
tests/data/data.tar.gz: application/gzip; charset=binary

If finfo and mime_content_type are not available file is used to determinate the mime type. On my machine it returns application/gzip. I guess that's the expected result because gzip is registered for a while: https://www.iana.org/assignments/media-types/application/gzip

We could probably add a third column to mimetypemapping.dist.json to specify a alternative syntax. Or replace / with /x- and check if one of them is a safe mime type.

Index: lib/private/Files/Type/Detection.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- lib/private/Files/Type/Detection.php	(revision 107ef72afba5f7d59614637736764ad1c092ff96)
+++ lib/private/Files/Type/Detection.php	(date 1576009620306)
@@ -266,13 +266,17 @@
 
 			if ($mimeType !== false) {
 				//trim the newline
-				$mimeType = trim($mimeType);
-				$mimeType = $this->getSecureMimeType($mimeType);
-				if ($mimeType !== 'application/octet-stream') {
-					return $mimeType;
+				$mimeTypeA = trim($mimeType);
+				$mimeTypeA = $this->getSecureMimeType($mimeTypeA);
+				if ($mimeTypeA !== 'application/octet-stream') {
+					return $mimeTypeA;
 				}
+				$mimeTypeB = str_replace('/', '/x-', trim($mimeType));
+				$mimeTypeB = $this->getSecureMimeType($mimeTypeB);
+				if ($mimeTypeB !== 'application/octet-stream') {
+					return $mimeTypeB;
+				}
 			}
-
 		}
 		return 'application/octet-stream';
 	}

It's dumb 🤣

@rullzer rullzer mentioned this pull request Dec 11, 2019
43 tasks
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
@rullzer rullzer merged commit c6e5192 into master Dec 12, 2019
@rullzer rullzer deleted the bugfix/noid/always-detect-mimetype-by-content-in-workflows branch December 12, 2019 10:19
@rullzer
Copy link
Member

rullzer commented Dec 12, 2019

/backport to stable17

@rullzer
Copy link
Member

rullzer commented Dec 12, 2019

/backport to stable16

@rullzer
Copy link
Member

rullzer commented Dec 12, 2019

/backport to stable15

@backportbot-nextcloud
Copy link

The backport to stable17 failed. Please do this backport manually.

@backportbot-nextcloud
Copy link

The backport to stable16 failed. Please do this backport manually.

@backportbot-nextcloud
Copy link

The backport to stable15 failed. Please do this backport manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants