Skip to content

Fix validation for mix of content types and exclusions#1386

Open
guikubivan wants to merge 1 commit intodanialfarid:masterfrom
haikulearning:guikubivan-validation-bug
Open

Fix validation for mix of content types and exclusions#1386
guikubivan wants to merge 1 commit intodanialfarid:masterfrom
haikulearning:guikubivan-validation-bug

Conversation

@guikubivan
Copy link
Copy Markdown

@danialfarid
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown

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
Copy Markdown

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

@danialfarid
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Owner

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

@danialfarid
Copy link
Copy Markdown
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