Bug 81393 - [test case] Space immediately after PRE tag is not ignored.
Summary: [test case] Space immediately after PRE tag is not ignored.
Status: RESOLVED FIXED
Alias: None
Product: konqueror
Classification: Applications
Component: khtml parsing (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: Konqueror Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-05-12 04:40 UTC by gjditchfield
Modified: 2005-03-21 20:10 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
Testcase from above. (557 bytes, text/html)
2004-05-12 13:15 UTC, Jan Schaefer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description gjditchfield 2004-05-12 04:40:05 UTC
Version:           3.2.2 (using KDE 3.2.2, SuSE)
Compiler:          gcc version 3.3.1 (SuSE Linux)
OS:                Linux (i686) release 2.4.21-215-default

If a <PRE> tag is followed by a space and then the end of the line, the space is not ignored; it is prepended to the start of the first line of the PRE's content.

I suspect that this was caused by an attempt to fix bug 47241 that deleted the end-of-line, but not the white space before it.

Here is a test file.
----------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 
        "http://www.w3.org/TR/html4/strict.dtd"> 
<html> 
<head>
<style>
PRE {background-color: red};
</style>
<body> 
<p>The start tag of this PRE element is followed by a space and then 
the end of the line.</p> 
<pre> 
An improperly formatted PRE element.
</pre> 
<p>The start tag of this PRE element is immediately followed by the end
of the line.</p>
<pre>
A properly formatted PRE element.
</pre>
<p>Note the space at the left margin of the first element.</p>
</body> 
</html>
Comment 1 Jan Schaefer 2004-05-12 13:15:08 UTC
Created attachment 5965 [details]
Testcase from above.
Comment 2 Jan Schaefer 2004-05-12 13:15:52 UTC
I can confirm this bug.
Comment 3 Allan Sandfeld 2005-03-21 19:50:46 UTC
On closer examination the correct behavior is to preserve every white-space when it is not a line-feed that follows the tag immediately.
Comment 4 Allan Sandfeld 2005-03-21 20:10:46 UTC
CVS commit by carewolf: 

Correct parsing of white-space immediately after pre tag. 
BUG: 81393


  M +4 -0      ChangeLog   1.406
  M +6 -8      html/htmltokenizer.cpp   1.299


--- kdelibs/khtml/ChangeLog  #1.405:1.406
@@ -1,2 +1,6 @@
+2005-03-21  Allan Sandfeld Jensen <kde@carewolf.com>
+
+        * html/htmltokenizer.cpp: Only skip first LF if immediately after PRE tag
+
 2005-03-18  Allan Sandfeld Jensen <kde@carewolf.com>
 

--- kdelibs/khtml/html/htmltokenizer.cpp  #1.298:1.299
@@ -1136,6 +1136,6 @@ void HTMLTokenizer::parseTag(TokenizerSt
             switch( tagID ) {
             case ID_PRE:
-                discard = LFDiscard;
                 prePos = 0;
+                discard = AllDiscard;
                 break;
             case ID_SCRIPT:
@@ -1365,10 +1365,8 @@ void HTMLTokenizer::write( const Tokeniz
             if ( pending ) {
                 // pre context always gets its spaces/linefeeds
-                if ( pre )
-                    addPending();
                 // only add in existing inline context or if
                 // we just started one, i.e. we're about to insert real text
-                else if ( !parser->selectMode() &&
-                          ( !parser->noSpaces() || dest > buffer )) {
+                if ( pre || script || (!parser->selectMode() &&
+                          ( !parser->noSpaces() || dest > buffer ))) {
                     addPending();
                     discard = AllDiscard;