Closed
Bug 265762
Opened 20 years ago
Closed 19 years ago
Javascript "invalid quantifier" message received when calling replace function
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
WONTFIX
People
(Reporter: mirzmaster+bugzilla, Unassigned)
References
Details
Attachments
(4 files)
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20040913 Firefox/0.10.1 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20040913 Firefox/0.10.1 I encountered this problem when looking into a defect report filed by a client that was having a problem in their migration to Netscape 7 (not sure which specific version). When a script tag has specified the language in type ONLY by using the now deprecated "language" attribute, a strange javascript error is encountered when attempting to replace the '+' or '*' characters. The replace function call is being made as such: var temp = str.replace("+", " "); Using that call will result in the following Javascript error: Error: invalid quantifier * There are three workarounds that I discovered: 1) Specify the language as "JavaScript" instead of a more specific version such as "JavaScript1.2". 2) Use the more acceptable "type" attribute. When specifying the type as "text/javascript" the script will run without error whether the language is specified or not. 3) Alternately, search for the '+' or '*' characters via regex, like so: var temp = str.replace(/\+/, " "); This problem was always reproducible on any Gecko embedding browser (Mozilla Suite, Netscape, Firefox) produced from a version of the Mozilla codebase, later than version 1.4. Where Netscape 7.1 would running the problem script without error, Netscape 7.2 would not. The following is a list of user-agents I tried and was successfully able to reproduce the problem with: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax) Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6) Gecko/20040113 Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20040913 Firefox/0.10.1 I did try Netscape 7.1 (based on Mozilla 1.4) and could run the problem script successfully. I did not record the exact user-agent string, unfortunately. I will attach 4 test cases -- 1 illustrating the problem, and 3 implementing the various workarounds. Reproducible: Always Steps to Reproduce: 1. Write script tag specifying a language of "JavaScript1.2" 2. Utilize 'replace' function to replace instances of the '+' or '*' characters in a string with any other character(s) 3. Run script. Actual Results: Recorded javascript error, " Error: invalid quantifier * ". Expected Results: Run through script successfully.
Reporter | ||
Comment 1•20 years ago
|
||
Reporter | ||
Comment 2•20 years ago
|
||
This testcase implements the script "type" workaround.
Reporter | ||
Comment 3•20 years ago
|
||
This testcase implements the language="JavaScript" workaround.
Reporter | ||
Comment 4•20 years ago
|
||
This testcase implements the regex workaround.
Comment 5•20 years ago
|
||
Deprecation (hardly effective in the real world) of language has nothing to do with the problem you see -- if you had used <script type="application/x-javascript;version=1.2"> you would have seen the same results. Why are you selecting 1.2? It's an ancient version, not compatible with ECMA-262 because it actually pre-dates the final Edition 1 spec, and our compatibility code was carried along from the days when Netscape had enough market share to matter. It seems IE and Opera do not make changes to JS syntax or semantics based on any version selector, so we're considering doing likewise for HTML scripts. More when I have time to analyze this in a fresh build. /be
Reporter | ||
Comment 6•20 years ago
|
||
Just a clarification: it is not my choice to use version 1.2. I work for a Fortune 500 company and our team supports a legacy application served to hundreds of thousands of users. To change all our script tags would require a monumental effort and a fairly large investment. One of our clients recently updated their workstations to use some version of the Mozilla suite (obviously later than 1.4), and our app broke. I implemented a workaround, but just filed the bug to in case the issue is due to a regression in the Moz JS Engine functionality. :)
Comment 7•20 years ago
|
||
Sohail, just for curiosity's sake, how are the files of your application stored? are they simply text files or are they embedded in a database? If they are in text files, a simple command line program can change strings of the form language="javascript1.2" to language="javascript" in an arbitrary number of files. The only outstanding issue would be caching of the files in your client's browsers.
Reporter | ||
Comment 8•20 years ago
|
||
bc, while I'd love to do that, the beaurocracy and overhead involved in doing that (not to mention the expense of regression testing every script in the application) would make it more plausible for our organization to fund a re-write of the entire Mozilla line of applications! :) Again, it's not in my control to do that. :)
Comment 9•19 years ago
|
||
background info (see the implementation note) http://bclary.com/2004/09/26/boot-camp-javascript#String.prototype.replace this behavior will change in firefox 1.1 and mozilla 1.8 due to bug 255895. considering this behavior is by design, marking invalid.
Status: UNCONFIRMED → RESOLVED
Closed: 19 years ago
Depends on: 255895
QA Contact: pschwartau → moz
Resolution: --- → WONTFIX
Reporter | ||
Comment 10•19 years ago
|
||
Bob, Thank you for your response, and for taking the time to reply to the bug. :) Your efforts are much appreciated! Sohail Mirza
You need to log in
before you can comment on or make changes to this bug.
Description
•