Column problem with a empty script tag

Marc Gueury <[email protected]>
Newsgroups gmane.comp.web.html-tidy.devel
Message-ID <[email protected]>
Hello all,

I was analyzing pages when I noticed that sometimes the column where the 
error was reported
was wrong for some pages.

Then I finished to make this testcase:

<html><head>
  <title>Google</title>
</head>
<body>
<script>
</script><a id=1a href="/imghp?hl=en&tab=wi">Images</a>
</body></html>

The output is output:
line 6 column 43 - Warning: unescaped & or unknown entity "&tab"

This should be:
line 6 column 37 - Warning: unescaped & or unknown entity "&tab"

First, I got the newest and the oldest version of Tidy.
It work in the old version and not in the last one

After some debugging, the reason of this is a change in lexer.c line 1838
The <script> tag being empty seems to cause a problem.

New Version (wrong)

            if (matches && nested-- <= 0)
            {
                for (i = lexer->lexsize - 1; i >= start; --i)
                    UngetChar((uint)lexer->lexbuf[i], doc->docIn);
                UngetChar('/', doc->docIn);
                UngetChar('<', doc->docIn);
                lexer->lexsize -= (lexer->lexsize - start) + 2;
                break;
            }
           
Old version (It works if I copy paste this code in the new one 
too)           

            if (matches && nested-- <= 0)
            {
                /* skip trailing white space in end tag */
                while (IsWhite(c))
                    c = ReadChar(doc->docIn);

                /* <script>...</script<p>... */
                if (c == '<')
                    UngetChar(c, doc->docIn);

                lexer->lexsize -= (lexer->lexsize - start) + 2;
                break;
            }

What can I do with this ?

Thanks by advance.

Marc          



-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE
LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.