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 197145 - Html validator doesn't flag a file as erroneous
Summary: Html validator doesn't flag a file as erroneous
Status: VERIFIED FIXED
Alias: None
Product: web
Classification: Unclassified
Component: HTML Editor (show other bugs)
Version: 7.0
Hardware: PC Mac OS X
: P2 normal (vote)
Assignee: Marek Fukala
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-28 09:02 UTC by Marek Fukala
Modified: 2011-07-27 11:13 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Options Dialog (58.38 KB, image/gif)
2011-05-06 08:50 UTC, bht
Details
New testcase (1.39 KB, text/html)
2011-06-02 10:14 UTC, bht
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Marek Fukala 2011-03-28 09:02:08 UTC
Extracted from the original issue 194939:

I have had some more time working with the fixed build.

As a consequence of the fix, some HTML errors, possibly due to the name-spaced
tags are now no longer flagged as errors but as warnings.

For example, if you try in the attachment "Testcase":
            <tr wicket:id="idRow">
                <th colspan="2">ID:</td>
                <td colspan="2" wicket:id="id">12356</td>
            </tr>

(the first <th> is unmatched (incorrectly matched by </td>)

then there is a yellow warning icon not a red one as in version 9.1.

I think we need the error flagging for the real HTML errors otherwise one
cannot see that the file is invalid as a whole.

I found this when I missed a </html> tag and the file was still valid.

You can try this with the testcase and there is no red icon as a conseequence.
Comment 1 Marek Fukala 2011-03-28 09:12:52 UTC
Warnings are used since most of the real word html source files simply contain them but the browsers interprets them well. Many users complained about too strict validation marking most of their "correct" files as erroneous.

As for the missing </html> ... it's optional.
Comment 2 bht 2011-03-28 16:13:07 UTC
Thanks for splitting the original issue. With the new HTML parser I feel we are walking on a cliff - hard to get it right.

I agree real HTML files contain errors and browsers ignore them in some cases.

I strongly disagree with your conclusion that the HTML editor should not mark errors as errors because of the fact that such errors exist in the wild, and because some users complain.

As serious developers we need meaningful validation in the editor, and NetBEans 6.9 does this for us.

While most browsers tolerate HTML errors in plain pages, they use strict unforgiving parsers for HTML fed into the DOM via JavaScript (eg AJAX).

The testcase is such an example - a Wicket panel. Wicket sends part of it to the browser as part of an AJAX response.

The browser uses a strict HTML parser for injecting HTML into the DOM via JavaScript, a parser that simply refuses to process invalid markup.

In our development process, the editor is currently our only tool that protects us from such errors.

Therefore we cannot accept that an HTML editor treats a missing end tag as a warning not an error.

This is even less acceptable in light of issue 197144. We have no problems whatsoever with NetBeans 6.9.
Comment 3 mcfedr 2011-04-14 21:12:51 UTC
I would also add that there can be problems with mixed html and php (i dont know about other languages)
for example

<a href="<?php echo $href; ?>">link</a>

gets flagged as an error because href cannot be empty, clear in this case it isn t (unless $href is empty, but then thats where it gets a bit blurry...)

also, at one point, though possibly not in the rc, i cannot remember, it marks errors in files that dont start with <html><head> etc... 
a lot of partial template files that are later included into other files are like this.

ideally these things wouldn't get marked as errors, but whilst they do i think it is best that files are not marked as containing errors because a lot of these are not 'real' errors...
Comment 4 bht 2011-04-14 22:14:06 UTC
PHP files are not HTML files, they are something else. The original issue 194939 is concerned with HTML only. This should possibly be reflected in the subject so we don't get distracted. I am concerned that malformed HTML documents, eg documents containing unmatched tags, are not currently flagged as erroneous.
Comment 5 Marek Fukala 2011-05-04 14:47:13 UTC
fixed in web-main#081b2f1f1b46

The html validator error checks are now configurable to some extent. I plan to do much more fine grained customization options for 7.1, but the current changes should cover the problem described in the issue.

There are some new hints options for HTML language in the editor options. There are three new subcategories of Html Validator category - Encoding issues, Tags matching issues and Others. 

You may enable/disable the particular hint or change its severity. If a hint is disabled, the tasklist should also does not show the errors from its category. The severity set in the hints options won't be reflected in the tasklist (will be implemented for 7.1). There will be a separate checkbox in "Show in tasklist" for each hint in 7.1 as well so it will be possible to have the hint enabled just for the editor and not for tasklist.

It may happen that some of the error messages from the validator are not properly added to the hint category (there's no central registry of the messages in the validator so I have to do some pattern recognition on the messages text). If you find such, please report it in a new issue. Thanks.
Comment 6 Quality Engineering 2011-05-05 06:07:29 UTC
Integrated into 'main-golden', will be available in build *201105050000* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/081b2f1f1b46
User: Marek Fukala <mfukala@netbeans.org>
Log: #197935 - Wrong Encoding Warning on HTML-Files - even NB7 own Templates ; #197145 - Html validator doesn't flag a file as erroneous
Comment 7 bht 2011-05-06 08:46:56 UTC
Thanks for adding this functionality.

I tried it with IDE Dev (Build 201105050000) and enabled HTML error with tag matching by removing the body end tag.

The result is an error text 'Fatal Error: the element type "body" must be terminated ...'

However, the icon in the left margin is the yellow warning icon and the file is not marked as erroneous.
Comment 8 bht 2011-05-06 08:50:04 UTC
Created attachment 108144 [details]
Options Dialog
Comment 9 Marek Fukala 2011-05-06 09:18:04 UTC
changeset:   193606:691f29ddeba0
summary:     #197145 - adding new message pattern to the TagsMatching rule

I'm sorry but I warned you there might be such issues :-). I would appreciate if you possibly gather some of the uncategorized messages before reopening the bug.

I'll go through the validator sources and try to categorize as much of the  messages as possible later. They are simply spread in the classes w/o any reasonable declaration in the messageEmitter.error("bla bla ...") way :-(
Comment 10 Marek Fukala 2011-05-06 13:01:56 UTC
I've went through part of the code and categorized some more messages to:

                        <file name="org-netbeans-modules-html-editor-hints-AttributeSyntax.instance"/>
                        <file name="org-netbeans-modules-html-editor-hints-CharacterReference.instance"/>
                        <file name="org-netbeans-modules-html-editor-hints-Comments.instance"/>
                        <file name="org-netbeans-modules-html-editor-hints-Doctype.instance"/>
                        <file name="org-netbeans-modules-html-editor-hints-ForeignContent.instance"/>
                        <file name="org-netbeans-modules-html-editor-hints-Form.instance"/>
                        <file name="org-netbeans-modules-html-editor-hints-Ids.instance"/>
                        <file name="org-netbeans-modules-html-editor-hints-Nesting.instance"/>
                        <file name="org-netbeans-modules-html-editor-hints-Normalization.instance"/>
                        <file name="org-netbeans-modules-html-editor-hints-ProcessingInstruction.instance"/>
                        <file name="org-netbeans-modules-html-editor-hints-StrayContent.instance"/>
                        <file name="org-netbeans-modules-html-editor-hints-Table.instance"/>
                        <file name="org-netbeans-modules-html-editor-hints-TagSyntax.instance"/>
                        <file name="org-netbeans-modules-html-editor-hints-UnexpectedChars.instance"/>
Comment 11 Quality Engineering 2011-05-07 05:34:25 UTC
Integrated into 'main-golden', will be available in build *201105070000* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/691f29ddeba0
User: Marek Fukala <mfukala@netbeans.org>
Log: #197145 - adding new message pattern to the TagsMatching rule
Comment 12 bht 2011-06-02 10:14:06 UTC
Created attachment 108669 [details]
New testcase

A new testcase does not show any error/warning.
Comment 13 Marek Fukala 2011-06-02 10:39:16 UTC
Bug 199104 - No error for unmatched <div> tag
Comment 14 Vladimir Riha 2011-07-27 09:11:36 UTC
verified, the problem described in first comment ("#0") works, there is red icon and there is a way to configure validator in Options