[links-list] Re: Cookies

Petr Baudis pasky at pasky.ji.cz
Sun May 5 09:28:18 PDT 2002


Dear diary, on Sat, May 04, 2002 at 04:03:11PM CEST, I got a letter,
where Jonas Fonseca <fonseca at diku.dk> told me, that...
> On Sat, May 04, 2002 at 10:26:09AM +0400, Khimenko Victor wrote:
> > > Is this hook able to handle this piece of (I think) legal javascript
> > > code as well ?
> > >
> > 
> > You think wrong. While it's legal javascript it's illegal HTML with
> > JavaScript :-)
> 
> Ok I got carried away a bit there. Sorry. :)
> But if this javascript code 
> 
> <SCRIPT type="text/javascript">
> 	document.write ("<EM>This will work<\/EM>")
> </SCRIPT> 
> 
> taken from here[1] is valid. And links handles this ok
> 
> <table><tr>
> 	<td>
> 	<script>document.write('<p> This is ignored.');</script>
> 	<noscript><p> This is displayed. </noscript>
> 	</td>
> </tr></table>
> 
> Then why can't it handle this ?
> 
> <table><tr>
> 	<script>document.write('<td> This is troublesome.');</script>
> 	<noscript><td> This should be diplayed but is not. </noscript>
> 	</td>
> </tr></table>
> 
> So it's ok to have <p> tags inside <script> strings but not <td>. 
> Is <td> handled in a special way ? Well I'm possibly missing the point.

It's inside table.

First, we must know that HTML parser is completely messy, full of nonsenses and
design flaws and terribly written, and then it works like that. Its problem is
that it doesn't work linearly, parsing the incoming code and saving it into
some kind of syntactic tree, then walking thru the tree and messing with it
somehow. No.

Here, I guess, the parser works like:

<table><tr>
	<script>document.write('<td> This is troublesome.');</script>
	<noscript><td> This should be diplayed but is not. </noscript>
	</td>
</tr></table>

1, <table> - cool! let's jump to nearest table element

<tr>
	<script>document.write('<td> This is troublesome.');</script>
	<noscript><td> This should be diplayed but is not. </noscript>
	</td>
</tr></table>

2, <tr> - great! seek for nearest table-type element

<td> This is troublesome.');</script>
	<noscript><td> This should be diplayed but is not. </noscript>
	</td>
</tr></table>

3, <td> - fine, let's extract everything to next table-type element

<td> This should be diplayed but is not. </noscript>
	</td>
</tr></table>

4, .....

So it completely skips the <script> tag, it is instructed to obviously skip its
contents otherwise.

Similiar problem arises when you've textarea inside table and table elements
inside textarea. I think this is not easily fixable and complete and correct
fix would mean rewrite of HTML parser to work in sensible way, which is
planned, but will happen in a bit more distant future.

> Another little strange behaviour I observed was that if two of the
> troublesome pieces of code is placed after another the second is handled
> alright. So it seems two wrongs make a right. Now that's a feature! ;)

;)))

> > Well - we can be glad Netscape and followers put this burden on
> > web-masters and not on web-browsers ...
> 
> Well I agree. Another question is how tolerant browsers should be toward
> invalid code. I think we agree on the web is full of crappy code what is
> links policy on this matter ?

If the needed effort is reasonable (which is very variable ;)), and it doesn't
break anything else, why not? :)

-- 
 
				Petr "Pasky" Baudis
 
* ELinks maintainer                * IPv6 guy (XS26 co-coordinator)
* IRCnet operator                  * FreeCiv AI hacker
.
Object orientation is in the mind, not in the compiler. -- Alan Cox
.
Public PGP key && geekcode && homepage: http://pasky.ji.cz/~pasky/
-- 
Unsubscribe: send email to links-list-request at linuxfromscratch.org
and put unsubscribe in the subject header of the message



More information about the links-list mailing list