Log in

No account? Create an account
entries friends calendar profile Previous Previous Next Next
Concerted effort - shadows of echoes of memories of songs — LiveJournal
Concerted effort
Read 18 | Write
simont From: simont Date: June 26th, 2006 03:47 pm (UTC) (Link)
It's not all tables, as closely as I can tell: it's tables which use implicit internal closing tags </td> and </tr>.

LJ's HTML cleaner has a bug in which it fails to mentally insert these where a real renderer would, and instead it builds up a list of close tags it hasn't seen yet. Then, at the end of the entry, it spews out a great big splurge of close tags, which means they come after the </table> within which they might have had a fighting chance of making sense.

This would be fine if it weren't for the fact that many LJ styles are also table-based, so all those close tags appearing at the end of the HTML for the actual entry blow away most of the table structure of the style. In a non-table-based style this isn't so problematic and browsers will just ignore the spew of spurious close tags.

I tried to prepare a patch at one time, but the code in that area was just too horrid for me to cope with without screaming. Instead, my own LJ style compensates for the bug by trimming </td> and </tr> tags off the end of the entry HTML before writing it into the output page. That usually works fine, but for some reason this entry of yours has managed to confuse even my style; I have yet to figure out what special case I've failed to allow for.
j4 From: j4 Date: June 26th, 2006 03:57 pm (UTC) (Link)
I suspect it is Not Actually A Bug for LJ to break when presented with invalid tables. My fault for not validating! (*looks sheepish*)

I have now fixed my table, so I think I'll un-cut it and see if people complain again...
simont From: simont Date: June 26th, 2006 04:01 pm (UTC) (Link)
Certainly it now doesn't cause the problem which it caused for me a moment ago.

However, that means I now can't use it to debug the defence in my LJ style code, which I was just about to attempt :-) Perhaps I should write a private LJ entry in an attempt to reproduce it myself...

Are implicit closing tags not permitted these days, then? I was under the impression that they might be deprecated, they might not be valid XHTML, and they might be so 1990s dahling, but they still weren't technically illegal.
j4 From: j4 Date: June 26th, 2006 04:14 pm (UTC) (Link)
Ah, hm, sorry about that. But I suspect you're right and you're better off reproducing the bugs you want in a private journal entry!

I was thinking of XHTML (because that's what we do here, theoretically), indeed. Not sure if implicit closing tags are illegal, but they're definitely morally wrong. 8-) You can validate your HTML 4.0 here if you want, but I'm afraid I don't have the energy to test it (or ferret through documentation) at the moment... sorry, just too lazy!
From: rgl Date: June 26th, 2006 04:19 pm (UTC) (Link)
I'm fairly sure implicit closing tags for table rows are still legal in HTML 4.01. The DTD says e.g.
<!ELEMENT TR - O (TH|TD)+ -- table row -->
where the "O" means optional IIRC
simont From: simont Date: June 26th, 2006 04:20 pm (UTC) (Link)
Aha, I've reproduced the problem. My defence didn't trigger because you put a tag on this entry: the bit of HTML that handles tags appears to be glued on to the entry's own HTML before my style code gets to process it, which means my defence code didn't see </tr> at the end of that string because it was somewhere in the middle.

Sigh. I'm not even sure I can compensate for that in my style code, since it would require me to do a much fuller job of HTML parsing; I may just have to fall back to the traditional method of whinging at people who trigger the bug :-/
imc From: imc Date: June 26th, 2006 04:32 pm (UTC) (Link)
Certainly XHTML requires all tags to be closed explicitly. I'm under the impression that in HTML 4 the closing tags for <tr> and <td> elements are optional (though you always used to have to put them in anyway in order to avoid breaking Netscape 4).

LiveJournal is aiming for XHTML compliance, but that's a nonsense: you're never going to be able to massage random user-supplied HTML into syntactically valid XHTML (and syntactically invalid XHTML is completely pointless in my view). Indeed, the page into which I'm typing this comment has an HTML 4 doctype, so strictly speaking all the XHTML self-closing tags on this page are syntactically invalid. [See previous rant.]

Anyway. The point of LiveJournal's HTML cleaner is that it's supposed to protect the LiveJournal environment from the effects of any bad HTML appearing within your entry; so if you can break it, it's definitely a bug regardless of whether or not the HTML you typed happened to be valid.
Read 18 | Write