Bug 212497 - NetBeans false parsing error in jsp: Bad value .. for attribute "href" on element "a"
NetBeans false parsing error in jsp: Bad value .. for attribute "href" on ele...
Status: RESOLVED WONTFIX
Product: javaee
Classification: Unclassified
Component: JSP Parser
7.1.2
PC Linux
: P3 with 6 votes (vote)
: TBD
Assigned To: issues@javaee
issues@javaee
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-05-14 19:11 UTC by agallardo
Modified: 2016-07-08 07:26 UTC (History)
2 users (show)

See Also:
Issue Type: ENHANCEMENT
:


Attachments
Screenshot: NetBeans parsing error for href attribute (174.83 KB, image/png)
2012-05-14 19:11 UTC, agallardo
Details

Note You need to log in before you can comment on or make changes to this bug.
Description agallardo 2012-05-14 19:11:59 UTC
Created attachment 119440 [details]
Screenshot: NetBeans parsing error for href attribute

For the following code:

   <%@page pageEncoding="UTF-8" 
           language="java"
           contentType="text/html" %>
   <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>


   <c:set var="myVar" value="0"/>
   <a href="#sec${myVar}"> Section ${myVar}</a>


NetBeans reports the following error in the '<a href'..'> line:

   Bad value "#sec  " for attribute "href" on element "a": DOUBLE_WHITESPACE in FRAGMENT.
   Syntax of IRI reference:
   Any URL. For example: '/hello', '#canvas', or 'http://example.org/'. Characters
should be represented in NFC and spaces should be escaped as '%20'.

See attachment.


Environment details
-------------------
Product Version: NetBeans IDE 7.1.2 (Build 201204101705)
Java: 1.7.0_03-icedtea; OpenJDK 64-Bit Server VM 22.0-b10
System: Linux version 3.2.12-gentoo running on amd64; UTF-8; en_US (nb)
Comment 1 agallardo 2012-06-13 15:58:52 UTC
This issue becomes very irritating, as in our JSPs we often build dynamically the "href" attribute. I have several files with too many of these distracting errors ("name" and "id" attributes for "a" element are also affected).

I also cannot understand why it seems that I'm the only one affected by these issue: I don't think that my scenario is too exotic. Am I missing something or doing something wrong? Or has the NetBeans parser been upgraded recently causing a regression? (Regression that no one has still noticed as JSP is a relatively old technology.)
Comment 2 agallardo 2012-06-14 20:13:01 UTC
Well, it is a bit embarrassing: I finally found the config option to turn off / tune this warning:

Tools -> Options -> Editor -> Hints -> HTML Validator -> Attributes

Changing it to "Enhancement," as it still holds true that the IDE should recognize that the attribute is built dynamically. I shouldn't need to turn off the validation for attributes off just because I'm editing JSPs.
Comment 3 pns 2013-03-08 23:34:37 UTC
This also happens with form elements if the "action" attribute is a EL variable, for example this:

<form name="my-post" action="${myArray['action']}" method="POST">

gives the error:

--------------------------------------------------------------------------------
Bad value "   " for attribute "action" on element "form": DOUBLE_WHITESPACE in PATH.
Syntax of IRI reference:
Any URL. For example: '/hello', '#canvas', or 'http://example.org/'. Characters should be represented in NFC and spaces should be escaped as '%20'.

From line 19, column 9; to line 19, column 58
(Rule Category: Attributes)
--------------------------------------------------------------------------------

This is extremely annoying when editing .jsp files!
Comment 4 paulflakstad 2013-10-11 14:22:54 UTC
I just installed NetBeans 7.3.1, full version, no plugins. My JSPs are now riddled with this "error", whereas the very same files were all error-free in version 7.0.1.

As far as I can tell, NetBeans won't allow a variable as an attribute's value. This surely cannot be the desired default behaviour of an advanced IDE.

To reproduce the error: 
1.) Create a JSP and define a String variable, e.g.: String myImgSrc = "http://url.com/image.jpg". 
2.) Use the variable as an attribute value, e.g.: <img src="<%= myValue %>" />

Taglibs are also affected: <img src="<my:tag>/some/path/here</my:tag>" /> will produce the error.

When it's not an attribute, all is fine. F.ex., <title><%= myTitle %></title> produces no error.

PS: In Tools -> Options -> Editor -> Hints -> HTML Validator -> Attributes I see nothing, except for an empty "Language" dropdown and a search field I can't use for anything.
Comment 5 paulflakstad 2013-10-11 14:42:43 UTC
Tested version 7.4 RC2. The issue is gone there. Well – almost... 

This line:
<html lang="<%= getLanguage() %>">

Produced this (equivalent) error:
Bad value "   " for attribute "lang" on element "html": The language subtag "   " is not a valid language subtag.
Syntax of language tag:
An RFC 5646 language tag consists of hyphen-separated ASCII-alphanumeric subtags. There is a primary tag identifying a natural language by its shortest ISO 639 language code (e.g. 'en' for English) and zero or more additional subtags adding precision. The most common additional subtag type is a region subtag which most commonly is a two-letter ISO 3166 country code (e.g. 'GB' for the United Kingdom). IANA maintains a registry of permissible subtags.
Comment 6 Martin Balin 2016-07-07 08:54:20 UTC
This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue.

Thanks for your cooperation,
NetBeans IDE 8.2 Release Boss
Comment 7 agallardo 2016-07-08 07:03:31 UTC
Thanks. I confirm that I cannot reproduce it in NetBeans 8.
Comment 8 agallardo 2016-07-08 07:10:45 UTC
(In reply to agallardo from comment #7)
> Thanks. I confirm that I cannot reproduce it in NetBeans 8.

My fault: the error pointed out in comment #5 is still present.
Comment 9 agallardo 2016-07-08 07:26:07 UTC
I filed https://netbeans.org/bugzilla/show_bug.cgi?id=262727 to track error reported in comment #5.


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo