Closed Bug 345589 Opened 18 years ago Closed 18 years ago

javascript: in href with single quote won't execute properly

Categories

(Firefox :: General, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: erm, Unassigned)

References

()

Details

User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.4) Gecko/20060508 Firefox/1.5.0.4
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.4) Gecko/20060508 Firefox/1.5.0.4

Error:missing ) after argument list
<a href='javascript:some_function("Something with a single quote &#039;");'>Something with a single quote '</a>

However ... this execute's just fine.

<a href="javascript:some_function('Something with a single quote &#039;');">Something with a single quote '</a>

Further testing shows
Error:unterminated string literal
<a href="javascript:some_function('Testing something with quotes &#039; &quot;');">Testing something with quotes ' "</a>

Error:unterminated string literal
<a href="javascript:set_note('Testing%20something%20with%20quotes%20%27%20%22');">Testing something with quotes ' "</a>


Reproducible: Always

Steps to Reproduce:
1.made a function called some_function() that basically did nothing.
2.ran various javascript: links
3.showed you the output

Actual Results:  
Errors when using php functions htmlentities, urlencode, and rawurlencode inside a <a href="javascipt:some_function('Text with a quote or double quote.');">link</a>


Error:missing ) after argument list
Error:unterminated string literal

Expected Results:  
Click the link, pass the text.
WFM with Mac trunk.  The first one,

<a href='javascript:some_function("Something with a single quote
&#039;");'>Something with a single quote '</a>

works as expected -- some_function is called with the string "Something with a single quote '"

The other three give "unterminated string literal" as expected, because if you mentally replace the HTML entities such as &#039; with characters such as ', you realize the JavaScript engine is in fact getting strings terminated early such as 'Something with a single quote ''.
No testcase, works fine for me per steps to reproduce, so...
Status: UNCONFIRMED → RESOLVED
Closed: 18 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.