Bug 141433 - [test case] Handling unclosed <style> elements
Summary: [test case] Handling unclosed <style> elements
Status: RESOLVED UNMAINTAINED
Alias: None
Product: konqueror
Classification: Applications
Component: khtml parsing (show other bugs)
Version: 3.5
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: Konqueror Developers
URL:
Keywords:
: 143476 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-02-09 12:34 UTC by Bernd Wurst
Modified: 2012-06-18 14:09 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
A little big-O demo (390.63 KB, text/html)
2007-06-13 20:19 UTC, Maksim Orlovich
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Bernd Wurst 2007-02-09 12:34:46 UTC
Version:            (using KDE KDE 3.5.6)
Installed from:    Gentoo Packages

When a HTML source contains a line like
<style type="text/css" />
konqueror acts as it was without /> at the end and wants to treat the whole file as a style definition.

Minimal Testcase:
http://www.schokokeks.org/~bernd/bugreport/konqueror-style.html

Valid XHTML 1.0 Strict but incorrectly displayed by konqueror
Comment 1 Tommi Tervo 2007-03-26 10:05:06 UTC
*** Bug 143476 has been marked as a duplicate of this bug. ***
Comment 2 Allan Sandfeld 2007-06-13 13:39:55 UTC
There is no such thing as <anything /> syntax in pure HTML(*). To make it work you need to serve the document as real XML-parsed XHTML.

* Actually if browsers had implemented true SGML-parsed HTML, this would actually mean short cut-notation: <div /> </div> would be equivalent to <div>&gt; &lt;</div>


SO DONT USE <anything /> IN HTML!
Comment 3 Felix Eckhofer 2007-06-13 13:51:20 UTC
What does that have to do with this bug-report? The example provided is xhtml and even if it weren't - not displaying the whole document because of this markup error just does not make sense.
Comment 4 Maksim Orlovich 2007-06-13 17:28:36 UTC
The example is NOT XHTML --- you're serving it as text/html.
What your bug really means is that we don't handle some broken HTML right.
Comment 5 Bernd Wurst 2007-06-13 17:35:48 UTC
Ok, sorry, my fault.

Please use http://www.schokokeks.org/~bernd/bugreport/konqueror-style.xhtml instead.

Same file, transmitted as application/xhtml+xml.
Comment 6 Felix Eckhofer 2007-06-13 17:50:34 UTC
Correct me if i'm wrong but RFC 2854 (http://www.rfc-editor.org/rfc/rfc2854.txt) says:
> In addition, [XHTML1] defines a profile of use of XHTML
> which is compatible with HTML 4.01 and which may also
> be labeled as text/html.
And according to http://www.w3.org/TR/xhtml1/#guidelines an empty element, which includes a space before the trailing '/>' is considered compatible.
While text/html may not be parsed as XML and therefore some parsing errors should *not* occur, I don't think there should be any visible difference between a *valid* XHTML document rendered in either mode.
Comment 7 Allan Sandfeld 2007-06-13 19:51:41 UTC
That's not what they mean in C.2, they just recommend including a space. We actually had handling of '/>' in one test release, and it caused severe problems because no other browser does. Seriously NO browsers parses '/>' in HTML mode.

What happens here in Firefox, is that it realize that the <style> is not terminated before the end of the file, and then reparses with the <style> element closed. Try the following as a demonstration:

<html>
<head>
<style>
</head>
<body>
<p>This is visible in Firefox, hidden in Konqueror
</body>
</html>

This is one of several dangerous parsing hacks in Firefox. We generally do not to implement broken stuff like that. 
Comment 8 Allan Sandfeld 2007-06-13 20:01:12 UTC
Let me rephrase the last comment: 
Actually we handle something similar with unclosed scripts, but we ignore many other unclosed things such as strings that firefox handles. Handling unclosed styles is a lot easier than unclosed strings, and be worthwhile if we really need it; but I would really prefer if we didn't have to implement such ugly hacks.
Comment 9 Maksim Orlovich 2007-06-13 20:17:43 UTC
Handling such things also requires the parser to be quadratic in complexity, which is quite undesirable (try opening a file I'll just attach, with a bunch of style tags in firefox!)

As for comment #5 -- there is a general bug with xhtml mimetype using HTML parsing, which is well known and will hopefully get fixed once I figure out some things about namespaces..
Comment 10 Maksim Orlovich 2007-06-13 20:19:07 UTC
Created attachment 20851 [details]
A little big-O demo
Comment 11 Maksim Orlovich 2007-06-13 20:22:21 UTC
Oh, and as the warning: don't open that file in any firefox/mozilla instances you want to use soon.
Comment 12 Maksim Orlovich 2007-06-13 20:24:43 UTC
.. On further thought, I think I take the quadratic thing back, as I think one can remember there is no </style> until some point, and treat any subsequent <style>'s as self-closing, but that would make the lexer even more horrendous..
Comment 13 Michael Leupold 2008-04-20 16:50:30 UTC
Still present in 3.5.9 and trunk r798768 using the file served with the correct xml content-type.
Comment 14 Myriam Schweingruber 2012-06-18 14:09:53 UTC
Message from the Bugsquad and Konqueror teams:
This bug is closed as outdated, as we do not have the manpower to maintain the KDE3 version anymore.
If you still can reproduce this issue with Konqueror 4.8.4 or later, please open a new report.
Thank you for your understanding.