Closed Bug 265885 Opened 20 years ago Closed 20 years ago

Problem with string literal argument conversion in Javascript

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: lester, Unassigned)

References

()

Details

User-Agent: Mozilla/5.0 (X11; U; Linux i686; rv:1.7.3) Gecko/20041001 Firefox/0.10.1 Build Identifier: Mozilla/5.0 (X11; U; Linux i686; rv:1.7.3) Gecko/20041001 Firefox/0.10.1 The page I have this problem is a bank one, so you'd need a Mexican account to check it out, so I'll explain the problem instead. Using this simple line could help understand what's happening here. <a href="javascript:alert('This should work'+'%0A'+'showing two lines in an alert');">Click here to test</a> What I would expect here is that the javascript engine parsed this line and send an alert with two lines: "This should work" and "showing two lines in an alert". But instead it just sends an error to the JS console with the following information: Error: unterminated string literal Source File: javascript:alert('This should work'+'%0A'+'showing two lines in an alert'); Line: 1, Column: 25 Source Code: alert('This should work'+' Yes, it "reads" the line correctly, but to execute it it parses the %0A (a carriage return) and thinks the line is incomplete. The bank page uses this as a submit "enter" to send information via a POST using a link (which calls a function and ultimately evals the '%0A' to "send" the POST. Here is some code for this page: This is the link: javascript:js_envia('T','1','A01B03','%0A','Consultas%C2%BBMovimientos'); And the code for "js_envia" is: function js_envia (tipo, activo,clave,liga,ruta) { pHeader.cgimenusRuta = ruta; document.FrmOpcion.action=pathcgis+'cgimenus.cgi'; document.FrmOpcion.activo.value=activo; document.FrmOpcion.tipo.value=tipo; document.FrmOpcion.clave.value=clave; document.FrmOpcion.submit(); if (liga != '') eval(liga); } var pHeader=null; pHeader= parent.GetPointerHd(); The important part is: if (liga != '') eval(liga); which evaluates the %0A to an enter and submits the information. Now, I don't know if this is the way Javascript should work, or if it's wrong, but this is the only reason I have to use Microsoft Explorer :( BTW, I've emailed the bank people and.. of course... they never answered. Reproducible: Always Steps to Reproduce: 1. Go to http://lesterchakyn.com/~lester/moz_test.html 2. Click on the link Actual Results: Nothing, and in the JS console appears an error about an unterminated string literal Expected Results: Display an alert with two lines. This has happened in Mozilla since 1.0, until 1.7.3, and Firefox 1.0PR
actually, this is working as intended... %0A in a url is a linebreak. string literals can not contain linebreaks. see also bug 249898 comment 1.
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago
Resolution: --- → INVALID
It may be worth filing an evangelism bug on the bank (which bank?).
You need to log in before you can comment on or make changes to this bug.