This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 178332 - Incorrect lexing of escaped quotation marks
Summary: Incorrect lexing of escaped quotation marks
Status: NEW
Alias: None
Product: javascript
Classification: Unclassified
Component: Editor (show other bugs)
Version: 6.x
Hardware: PC Linux
: P4 normal (vote)
Assignee: Petr Pisl
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-12-08 18:17 UTC by voidlogic
Modified: 2013-07-19 08:16 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description voidlogic 2009-12-08 18:17:39 UTC
Syntax highlighting error in JSP using JSF 1.2

The following code DOES NOT have a syntax highlighting error:

1: <h:commandLink value="Print"
2: onclick="printEvent(#{event.id},'#{event.name}'); return false;"
3:style="background: url(/NPS/faces/img/printer.png) no-repeat; padding-left: 20px;"/>

This version is correct also, but the IDE says there is a syntax error on line 2:

1: <h:commandLink value="Print"
2: onclick="printEvent(#{event.id},\"#{event.name}\"); return false;"
3:style="background: url(/NPS/faces/img/printer.png) no-repeat; padding-left: 20px;"/>

The second version keeps ' chars in the bean output from escaping the javascript function.

Please fix :)
Comment 1 Max Sauer 2009-12-09 00:55:26 UTC
Reassigning to JSP editor.
Comment 2 Marek Fukala 2009-12-09 02:03:59 UTC
This is a generic html lexing bug. In the following example onclick attribute value is finished on the first occurance of quotation mark, even if it is escaped.

<div onclick="alert(\"hello\")"/>
Comment 3 Marek Fukala 2009-12-09 02:17:55 UTC
I'm not sure how browser interprets the \xxx escapes in javascript, but according to the HTML spec you should use the &#xxx; form.
Comment 4 voidlogic 2009-12-13 19:34:10 UTC
>>I'm not sure how browser interprets the \xxx escapes in javascript, but
>>according to the HTML spec you should use the &#xxx; form.

Either JSF or Tomcat converts the escaped \" into a &quot; before it gets the browser.

Since the content of the onXXX= "..." event attribute is javascript, do javascript or HTML rules apply? I was assuming the javascript syntax rules were what mattered here, but I really have no idea.

Thanks.
Comment 5 Marek Fukala 2009-12-14 04:09:21 UTC
(In reply to comment #4)
> >>I'm not sure how browser interprets the \xxx escapes in javascript, but
> >>according to the HTML spec you should use the &#xxx; form.
> 
> Either JSF or Tomcat converts the escaped \" into a &quot; before it gets the
> browser.
This is strange since for me the JSF facelets compiler cannot even compile such page.

> 
> Since the content of the onXXX= "..." event attribute is javascript, do
> javascript or HTML rules apply? I was assuming the javascript syntax rules were
> what mattered here, but I really have no idea.
The only way how I made it work is to use the html entity references in the javascript code or use single quote for the onclick value and then use unquoted double qoute inside.

> 
> Thanks.
Comment 6 voidlogic 2009-12-16 07:31:36 UTC
>>This is strange since for me the JSF facelets compiler cannot even compile such
>>page.

I don't know then, unfortunately all I can tell you is that from a functionality standpoint the page works fine and when I go to the web browser I see a &quot; where the \" used to be. This page is a JSF 1.2 standard JSP page (not XML) hosted by Tomcat 6.0.18. If you would like I could attach an example page.

>>The only way how I made it work is to use the html entity references in the
>>javascript code or use single quote for the onclick value and then use unquoted
>>double qoute inside.

Understood. I thought this was a bug because I was getting a syntax error on a page which actually functions without any issues. But I see now that something else is being more forgiving than the standards specify. 

I would suggest marking this bug WONTFIX or INVALID.

Thank you for your time, I hope I did not waste too much of it.
Comment 7 Marek Fukala 2010-04-27 12:24:29 UTC
I've fixed the problem of closed html tag attribute value if there is an escaped qoute inside it in web-main#2594535d5821.

However this doesn't mean the issue is fixed - now the escaped quotes are passed to the javascript lexer which cannot properly handle them.
Comment 8 Quality Engineering 2010-04-28 05:07:09 UTC
Integrated into 'main-golden', will be available in build *201004280200* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/
User: 
Log: