Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File extension validation breaks after update to PHP 8.1.3 and Yii 2.0.45 #19313

Closed
michalwoz opened this issue Mar 18, 2022 · 1 comment
Closed

Comments

@michalwoz
Copy link
Contributor

What steps will reproduce the problem?

['file', 'file',
    'extensions' => ['png','jpg'],
],

What is the expected result?

Allow *.jpg and *.png

What do you get instead?

All extensions including jpg and png are considered invalid.

The problem is here:

if (PHP_VERSION_ID >= 80100) {
return static::getMimeTypeByExtension($file, $magicFile);
}

The $file which is analysed in above function is the temporary file with .tmp extension on Windows and no extension (/tmp/xxxxx) on Linux. We cannot get "getMimeTypeByExtension" from it.

Adding 'checkExtensionByMimeType' => false, to validation rules solved the problem for me. Is that expected behaviour?

Additional info

Q A
Yii version 2.0.45
PHP version 8.1.3
Operating system Windows/Linux
@michalwoz
Copy link
Contributor Author

Duplicate of #19307

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant