Closed Bug 440677 Opened 17 years ago Closed 17 years ago

bug with regular expressions check with firefox 3

Categories

(Core :: JavaScript Engine, defect)

1.9.0 Branch
x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 405630

People

(Reporter: tomek, Unassigned)

Details

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14 Code below always returns 'bad format'. Its just filename check. Works fine in firefox 2 and ie's var pattern=/^.*[\/|\\][A-Za-z0-9_\-. ]+\.[A-Za-z0-9]+$/i; var file = $('#new_file'); //jquery - the file input if(!pattern.test($(file).val())) { alert('bad format'); } Reproducible: Always Steps to Reproduce: 1. 2. 3. its a part of ajax file uploader.
Version: unspecified → 3.0 Branch
Assignee: nobody → general
Component: General → JavaScript Engine
Product: Firefox → Core
QA Contact: general → general
Version: 3.0 Branch → 1.9.0 Branch
I don't know enough about jquery to break this down quickly. jresig, do you mind simplifying this testcase for me (I'm hoping it will take you seconds instead of minutes)?
basically line $('#new_file') is equal to document.getElementById('new_file') which is file input field. and tests its value (!pattern.test($(file).val())) againts the regular expression above (/^.*[\/|\\][A-Za-z0-9_\-. ]+\.[A-Za-z0-9]+$/i;). It use to work with various browsers, but it doesnt with firefox 3.
Tomek: For what input(s) does the expression fail, then?
/^.*[\/|\\][A-Za-z0-9_\-. ]+\.[A-Za-z0-9]+$/i.test("/a.a") That seems to work correctly for me (returning true, not false).
Incidentally, since you're using /i, you needn't do A-Za-z, just A-Z will suffice. :) Please provide an example like the one I gave in comment #4, so that I can see the regexp and string which you think -should- match, but which doesn't. Thanks, Brian
input is any input field, the content (value) of that input is path to the file, basically this regular expression check use to work with paths to files and file names and now it doesnt. It fails (only in firefox 3) and it's not important what happens later mate, as it should not fail. Example values: C:\my_file.jpg or /home/some_folder/my_file.pdf
Firefox 3 input type="file" elements do not contain the full path to files any more, only the file name. I suspect therefore that this is a duplicate of bug 405630 and that you will need to change your validation logic to suit.
I agree with comment #7
Status: UNCONFIRMED → RESOLVED
Closed: 17 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.