Bug 110926

Summary: Konqueror errorneously interpretes CSS comment as HTML one
Product: [Applications] konqueror Reporter: Candid Dauth <cdauth+bugs.kde.org>
Component: khtml parsingAssignee: Konqueror Bugs <konqueror-bugs-null>
Status: RESOLVED NOT A BUG    
Severity: normal    
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Testcase that shows the bug.

Description Candid Dauth 2005-08-16 22:46:07 UTC
Version:            (using KDE KDE 3.4.1)
Installed from:    Compiled From Sources
OS:                Linux

I'm sorry if this bug has already been fixed but I've got only KDE 3.4.1 at the moment.

Well, see testcase. The <!-- in the style block is a CSS comment, that was originally used so that Netscape 1 wouldn't show the CSS/JS code in style/script elements. Many web pages still use it today.

So, I "forgot" to "close" that comment in the testcase, actually I don't have to close it because it's a CSS comment and it only marks the end of its line as commented out. But Konqueror takes it as HTML comment and ignores the HTML code after the style information. It's quite weird that Konqueror even shows the background colour as red then.

Konqueror should -- like Firefox does -- show the popup at loading and the background colour should be green.
Comment 1 Candid Dauth 2005-08-16 22:47:12 UTC
Created attachment 12242 [details]
Testcase that shows the bug.
Comment 2 Thiago Macieira 2005-08-22 00:58:44 UTC
<!-- [something] --> is an SGML comment and is valid in XML.

So, for Konqueror, your page is:
		<style type="text/css">
		</script>
		<style type="text/css">
			body { background-color:#0f0; }
		</style>

So, it's completely wrong. The Konqueror parsing is correct.
Comment 3 Candid Dauth 2005-10-12 00:04:47 UTC
> <!-- [something] --> is an SGML comment and is valid in XML.

In XML it would be, but in this case it’s HTML. According to the HTML DTD, both <style> and <script> contain #PCDATA, which means that HTML code inside them may not be interpreted. The #PCDATA block is closed by “</”, so the comment shouldn’t be interpreted like a comment but like PCDATA.