Bug 128566

Summary: Rendering of pages at http://www.linux.com is incorrect
Product: [Applications] konqueror Reporter: Hervé Fache <herve>
Component: khtmlAssignee: Konqueror Developers <konq-bugs>
Status: RESOLVED FIXED    
Severity: normal CC: edulix, fd0man, ismail, mail, mariusst
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Ubuntu   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: "noads" - exported expressions
html code shown as normal text
patch

Description Hervé Fache 2006-06-03 15:18:18 UTC
Version:            (using KDE KDE 3.5.3)
Installed from:    Ubuntu Packages
OS:                Linux

Was fine with 3.5.2, now the page is all upside down with items missing.

Viewing an article (http://www.linux.com/article.pl?sid=06/04/13/2057243) is even worse.

Sorry!
Comment 1 Adam Tulinius 2006-06-04 17:02:06 UTC
http://hackersbay.org/pub/screenshots/konqueror-bug-128566.png

something is certainly wrong :|

KDE 3.5.3 build from gentoo packages with gcc 3.4.6
Comment 2 Thiago Macieira 2006-06-10 00:38:23 UTC
I cannot confirm. It works fine for me (r548000).
Comment 3 Tommi Tervo 2006-06-10 01:45:33 UTC
Try to disable adblock, that worked for me.
Comment 4 Carsten Lohrke 2006-06-11 23:49:08 UTC
Created attachment 16561 [details]
"noads" - exported expressions

> Try to disable adblock, that worked for me. 

Right, that "works".


A Gento user reported¹ the issue and I can reproduce it
(linux.com,newsforge.com,freashmeat.net broken, slasdot.org, sourceforge.net
work - didn't test others) as well, both with stock KDE 3.5.3 and KDE 3.5.3
plus a few khtml branch patches.


[1] https://bugs.gentoo.org/show_bug.cgi?id=136265
Comment 5 Tommi Tervo 2006-06-15 16:23:05 UTC
*** Bug 129192 has been marked as a duplicate of this bug. ***
Comment 6 Marco Gusy 2006-06-16 14:32:10 UTC
I confirm ( Gentoo, built from sources, gcc i686-pc-linux-gnu-3.4.5 )

It's an issue with adblock, because deactivating it solves the problem
Comment 7 Tommi Tervo 2006-06-20 14:42:59 UTC
*** Bug 129483 has been marked as a duplicate of this bug. ***
Comment 8 Allan Sandfeld 2006-06-20 14:49:22 UTC
So is it a problem with adblock, or a problem with users of adblock making way to generic filters?
Comment 9 Tommi Tervo 2006-06-20 15:16:54 UTC
3.5.3 regression, 3.5.2 works fine with same adblock filter-set. Spart fixed one site, http://lists.kde.org/?l=konq-bugs&m=115067293831178&w=2
Comment 10 Germain Garand 2006-06-20 15:55:02 UTC
it's certainly possible the #128944 problem caused a lot more harm... ;(
Did someone tried with r552743 and see if those problems persist?
Comment 11 Tommi Tervo 2006-06-20 16:02:43 UTC
I've r552786 and problem is still around. Fix worked for heise.de
Comment 12 Germain Garand 2006-06-20 16:42:57 UTC
OK. Still, some symptoms described sounds disturbingly like tokenizer problems carewolf experienced after my changes for #91701.

Tommi, could you try to svn up -r522000 on html/htmltokenizer.{h,cpp} and see it that changes things?
Comment 13 Tommi Tervo 2006-06-20 22:15:02 UTC
Yeah, it works indeed.
Comment 14 Germain Garand 2006-06-20 22:54:13 UTC
Great.. :( 
good news is I can at least reproduce now by using the set of filters described in #4. Investigating will be much easier for me.
Comment 15 Marco Gusy 2006-06-21 00:37:44 UTC
Created attachment 16731 [details]
html code shown as normal text
Comment 16 Marco Gusy 2006-06-21 00:38:52 UTC
Comment on attachment 16731 [details]
html code shown as normal text

Don't know if this helps, but I noticed that sometimes, when this problem
occours, some html code is shown in the page. Maybe the adblock feature deletes
some html tags delimiter making the tag rendered as visible text, which
corrupts the page rendering.
(think at a page where the main "<table>" tag is replaced with "<table")
Comment 17 Michael Trausch 2006-06-21 00:51:30 UTC
On Tue, June 20 2006 18:37, Marco Gusy wrote:
>
> Created an attachment (id=16731)
>  --> (http://bugs.kde.org/attachment.cgi?id=16731&action=view)
> html code shown as normal text
>


This attachment shows the problems that I was having until I turned off the 
ad blocker in Konqueror 3.5.3, with newsforge.com stories and 
freshmeat.net, or any other OSTG web site.

	- Mike
Comment 18 Germain Garand 2006-06-21 02:55:02 UTC
Created attachment 16734 [details]
patch

allright, I think I have it mostly worked out.

The thing is that the tokenizer currently clobbers everything that might still
be left in its src string when a new input is to be tokenized.

Usually this doesn't happen, because incoming data is stored in a waiting
queue, but this queue is bypassed in a few cases, namely:
- when the tokenizer is put on hold and then restarted, 
- in the new script handler, when a nested script is filtered or disallowed
while another script is running, the queue is flushed directly to the tokenizer
src.

Hence the attached patch:
  1) generally fixes the clobbering
  2) modifies script handler to avoid flushing its pending queue to ::write
when script execution is denied.

Please test..
Comment 19 Michael Trausch 2006-06-21 03:21:16 UTC
On Tue, June 20 2006 20:55, Germain Garand wrote:
>
> Hence the attached patch:
>   1) generally fixes the clobbering
>   2) modifies script handler to avoid flushing its pending queue to
> ::write when script execution is denied.
>
> Please test..
>


Will do as soon as I figure out why I can't seem to build anything... 
hopefully somebody else will be able to test sooner then I.

	- Mike
Comment 20 Tommi Tervo 2006-06-21 09:53:34 UTC
Patch works very well. Thanks a lot Germain.
Comment 21 Ismail Donmez 2006-06-21 13:51:14 UTC
Another confirmation from here, thanks Germain.
Comment 22 Germain Garand 2006-06-21 15:37:53 UTC
SVN commit 553547 by ggarand:

.don't clobber whatever content is left in the Tokenizer source string when setting a new string
.don't let scriptHandler flush any queue when the current script has been filtered out or disallowed

Hopefully closes this horrible script handling Pandora box for good..

BUG:128566



 M  +9 -3      htmltokenizer.cpp  


--- branches/KDE/3.5/kdelibs/khtml/html/htmltokenizer.cpp #553546:553547
@@ -414,6 +414,9 @@
             setSrc(TokenizerString());
             scriptCodeSize = scriptCodeResync = 0;
             scriptExecution( exScript, QString::null, tagStartLineno /*scriptStartLineno*/ );
+        } else {
+            // script was filtered or disallowed
+            effectiveScript = false;
         }
     }
 
@@ -428,8 +431,8 @@
     } else if ( cachedScript.isEmpty() ) {
         write( pendingQueue.pop(), false );
     } else if ( !deferredScript && pendingQueue.count() > 1) {
-       TokenizerString t = pendingQueue.pop();
-       pendingQueue.top().prepend( t );
+        TokenizerString t = pendingQueue.pop();
+        pendingQueue.top().prepend( t );
     }
 }
 
@@ -1318,7 +1321,10 @@
         return;
     }
 
-    setSrc(str);
+    if (!src.isEmpty())
+        src.append(str);
+    else
+        setSrc(str);
     m_abort = false;
 
 //     if (Entity)
Comment 23 Tommi Tervo 2006-06-27 13:54:06 UTC
*** Bug 129901 has been marked as a duplicate of this bug. ***
Comment 24 Tommi Tervo 2006-07-02 13:14:37 UTC
*** Bug 130141 has been marked as a duplicate of this bug. ***