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.
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 :)
Reassigning to JSP editor.
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\")"/>
I'm not sure how browser interprets the \xxx escapes in javascript, but according to the HTML spec you should use the &#xxx; form.
>>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 " 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.
(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 " 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.
>>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 " 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.
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.
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: