-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Core: Extract the file name without including "C:\fakepath\" #1651
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
Conversation
Just remembered this and wondering why this should be added to the plugin if we have a JUST WONDERING
Finally, I think this PR should remain open until someone else claim about that. @staabm what do you think ? |
With this change we only cut the A user might validate the input file-name/path because of certain length restrictions in the db (e.g. Also as described in #1615 the maxlength and minlength options do not work correctly because of the magic-prefix. |
The browser will send the file name prefixed by
Make sense. Thanks for the explanation :) I've handled that in one of my project by generating a new name for the file (so the original name doesn't matter anymore, and sometimes using the title as name) and rely on the title that the user should enter.
Yes, so the PR still valid :D |
@Arkni what do you think about adding a test for min or max length check for a file input? |
Make sense as the issue we are trying to solve was about that. |
@staabm please double check. If you have a better way to do the test, please let me know. |
fileInput.value = "C:\\fakepath\\fakefile.txt"; | ||
ok( !v.check( fileInput ), "The fake file input is invalid (length = 12, maxlength = 10)" ); | ||
|
||
$.fn.rules = oldRules; |
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.
why resetting to oldRules
and oldvalidationTargetFor
?
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.
in order to not affect other tests, I guess :)
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.
@Arkni each test should live in its sandbox and the testframework is responsible for this kind of cleanup (I am not sure though qunit supports my assumption) ;)
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.
I dont remember other unit tests doing such cleanup, so I am pretty sure we would have a lot of problems in case qunit would not already clean those things up (or boots a fresh environment for each test)
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.
I dont remember other unit tests doing such cleanup, so I am pretty sure we would have a lot of problems in case qunit would not already clean those things up (or boots a fresh environment for each test)
I don't see such thing in their documentation (If I didn't miss something).
I guess we should ask someone from the core team for an answer, I don't know if jzaefferer has the time to do so.
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.
But we should always play it safe ;)
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.
OK, get ride of monkey patch rules()
and used public api for validation :)
6a6c245
to
9054789
Compare
For historical reasons, the value IDL attribute prefixes the file name with the string "C:\fakepath\". As a result of this, this fix will extract the file name from the value IDL attribute in a backwards-compatible way. For more details, see: - http://www.w3.org/TR/html5/forms.html#dom-input-value-filename - http://www.w3.org/TR/html5/forms.html#fakepath-srsly Fixes jquery-validation#1615
For historical reasons, the value IDL attribute prefixes the file name
with the string "C:\fakepath". As a result of this, this fix will extract
the file name from the value IDL attribute in a backwards-compatible way.
For more details, see:
Fixes #1615