fix: Avoid failing with duplicate checks

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl 2023-02-23 13:04:32 +01:00
parent e9df5b22c4
commit 13d5407085
No known key found for this signature in database
GPG key ID: 4C614C6ED2CDE6DF
2 changed files with 4 additions and 10 deletions

View file

@ -107,13 +107,7 @@ class FileMimeType extends AbstractStringCheck implements IFileCheck {
* @return bool
*/
public function executeCheck($operator, $value) {
$actualValue = $this->getActualValue();
$plainMimetypeResult = $this->executeStringCheck($operator, $value, $actualValue);
if ($actualValue === 'httpd/unix-directory') {
return $plainMimetypeResult;
}
$detectMimetypeBasedOnFilenameResult = $this->executeStringCheck($operator, $value, $this->mimeTypeDetector->detectPath($this->path));
return $plainMimetypeResult || $detectMimetypeBasedOnFilenameResult;
return $this->executeStringCheck($operator, $value, $this->getActualValue());
}
/**

View file

@ -127,7 +127,7 @@ class FileMimeTypeTest extends TestCase {
$check = new FileMimeType($this->l10n, $this->request, $this->mimeDetector);
$check->setFileInfo($storage, 'foo/bar.txt');
$this->assertTrue($check->executeCheck('is', 'text/plain-path-detected'));
$this->assertTrue($check->executeCheck('is', 'text/plain-content-detected'));
}
public function testFallback() {
@ -142,7 +142,7 @@ class FileMimeTypeTest extends TestCase {
public function testFromCacheCached() {
$storage = new Temporary([]);
$storage->mkdir('foo');
$storage->file_put_contents('foo/bar.txt', 'asd');
$storage->file_put_contents('foo/bar.txt', 'text-content');
$storage->getScanner()->scan('');
$check = new FileMimeType($this->l10n, $this->request, $this->mimeDetector);
@ -156,7 +156,7 @@ class FileMimeTypeTest extends TestCase {
$newCheck = new FileMimeType($this->l10n, $this->request, $this->mimeDetector);
$newCheck->setFileInfo($storage, 'foo/bar.txt');
$this->assertTrue($newCheck->executeCheck('is', 'text/plain-path-detected'));
$this->assertTrue($newCheck->executeCheck('is', 'text/plain-content-detected'));
}
public function testExistsCached() {