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

Fix validation for mix of content types and exclusions #1386

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

guikubivan
Copy link

@danialfarid
Copy link
Owner

Can you elaborate more how that change fixes the problem? That issue was closed and marked as fixed, so you should probably create a new issue or have that re-opened first so we know what the issue is that this PR is fixing. Can you provide steps to reproduce of the issue.

@guikubivan
Copy link
Author

You're adding a | to the end of the inclusion expression when there is more than one validation, regardless if the other validations are inclusion regexp or exclusions. Therefore you end with an expression that accepts anything. Type this in your JS console to see what I mean: new RegExp('(blah)|').test('bleh'). It will return true.

@danialfarid
Copy link
Owner

It doesn't add | to the end of the expression. The if condition in the loop is there for that reason, so there is no ending |

@guikubivan
Copy link
Author

@danialfarid Please look at fiddle from issue #1026: http://jsfiddle.net/sufius/k6ahsu1n/4/ to replicate the issue. Notice dropzone has the following attribute: ngf-pattern="'image/*,!.jpg'". Try to upload text, zip, pdf, or any other file. They will all be uploaded. I don't think that's the correct behavior.

Or go to your demo site and enter image/*,!.jpg in the accept field. Try to upload a non-image file, they will all upload.

@lukebultman
Copy link

We've attempted testing things on your demo - https://angular-file-upload.appspot.com/, and we're confused why we're allowed to upload non-image files. (see screenshot)
non image files

@lukebultman
Copy link

Do you have a scheduled release date for the enhancement tag you put on the PR?

@danialfarid
Copy link
Owner

Could be a month.
For now you can have custom validation ngf-validate-fn and validate the file.type against whatever criteria you have.

@guikubivan
Copy link
Author

Any updates on this @danialfarid. It would be nice to not have to fork the project in order to have this working.

@danialfarid
Copy link
Owner

I have changed the logic here for version angular2 and it might be ported back to version 1.

@danialfarid
Copy link
Owner

I also still don't see what's the difference between this PR and the old code. How this PR gonna fix the issue?

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.

3 participants