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
Support for composite file extension validation #18137
Conversation
@saidbakr would you please test it? |
I will test as soon as possible today. |
Please, could you tell me how to update Yii to the latest development version. I use basic app and I have tried,
|
@saidbakr u can try: |
It's valid, but this changes is not merged into dev-master |
@saidbakr no, it's not dev version. It is a fork. Either you can try specifying it or do a hot-patch manually by overwriting files in vendor (just for testing). |
I have copied the two files to there paths in vendor/yiisoft, changed the server port |
At least something :) |
@saidbakr would you please share your validator config? |
It is in a previous comment. However, it is here again:
|
Would you please add: 'checkExtensionByMimeType' => false as we've discussed in the issue? |
Oh no, I am sorry, I forgot it!
However, we may have to make an Ajax validation to reflect the absence of |
Another note: is there any problem to change the property name from |
@saidbakr that's not the same thing: /**
* @var bool whether to check file type (extension) with mime-type. If extension produced by
* file mime-type check differs from uploaded file extension, the file will be considered as invalid.
*/
public $checkExtensionByMimeType = true; Setting it to |
Do you mean AJAX or client validation? |
I don't think that JavaScript as a client side could able to check mimetype. So I regarded Ajax. The current implementation tells that JavaScript just check the extension as a string only. |
It is currently doing that :) https://github.com/yiisoft/yii2/blob/master/framework/assets/yii.validation.js#L419 |
Very good, the last update of
I think in the case of
|
Side Note
Without clearing |
In case it's turned off, mime-type isn't automatically checked but you can still specify it via |
@rob006 would you please take a look at the code? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests are missing.
Thank you for putting effort in the improvement of the Yii framework. In order for the framework and your solution to remain stable in the future, we have a unit test requirement in place. Therefore we can only accept your pull request if it is covered by unit tests. Could you add these please? Thanks! P.S. If you have any questions about the creation of unit tests? Don't hesitate to ask for support. More information about unit tests This is an automated comment, triggered by adding the label |
Let me explain the issue in other words: 1 Starting with validation below in the model:
2 Trying to upload file named
|
Co-authored-by: Robert Korulczyk <robert@korulczyk.pl>
That is expected. We don't have a list of mime types on the client so leaving that to server validation. |
Thanks! |
Support for composite file extension validation (#18094)