Bug 116790 - Hidden field is not sent
Summary: Hidden field is not sent
Status: RESOLVED FIXED
Alias: None
Product: konqueror
Classification: Applications
Component: khtml forms (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: Konqueror Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-11-20 21:59 UTC by Christian Spitzlay
Modified: 2006-07-18 15:34 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
Stripped HTML page that reproduces the problem (361 bytes, text/html)
2005-11-20 22:01 UTC, Christian Spitzlay
Details
simpler testcase (226 bytes, text/html)
2005-11-20 23:57 UTC, Niels
Details
Patch (533 bytes, patch)
2005-11-21 00:10 UTC, Allan Sandfeld
Details
Test case (6.90 KB, text/html)
2006-06-19 11:54 UTC, Allan Sandfeld
Details
Patch (1.09 KB, patch)
2006-06-19 12:03 UTC, Allan Sandfeld
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Spitzlay 2005-11-20 21:59:44 UTC
Version:            (using KDE KDE 3.5.0)
Installed from:    Unlisted Binary Package
OS:                Linux

Browsing the site http://www.osnews.com/ I noticed that comments posted with Konqueror are not associated with a thread while when posted with Firefox they are.  It turned out that Konqi doesn't send a hidden field that carries the parent post info.

I stripped down the HTML as much as possible and the problem lies here (see also attached page): 

<tr>
<td>
<font>
<p>
<input type="hidden" name="ref" value="62637">
</font>
</td>
</tr>


If I remove either the <font>, the </font> or the <p> tag the hidden field reappears in the request. 

---

Here is my version info (I'm using the experimental Debian 3.5 packages): 

> konqueror -v
Qt: 3.3.5
KDE: 3.5 (RC1)
Konqueror: 3.5
Comment 1 Christian Spitzlay 2005-11-20 22:01:38 UTC
Created attachment 13572 [details]
Stripped HTML page that reproduces the problem
Comment 2 Allan Sandfeld 2005-11-20 23:49:59 UTC
Sorry, how do I configure something to use that test?
Comment 3 Niels 2005-11-20 23:57:31 UTC
Created attachment 13573 [details]
simpler testcase

Here's a simpler testcase. Note that there's no table tag.
Comment 4 Christian Spitzlay 2005-11-21 00:02:40 UTC
Ah yes, sorry, I had written a little php script that dumped the passed parameters.  But I guess Niels' test case using method='get' will be sufficient, won't it?
Comment 5 Allan Sandfeld 2005-11-21 00:10:40 UTC
Created attachment 13575 [details]
Patch

This patch fixes it by improving fall-back behaviour

I am not sure it is the right way(TM). The real problem is that the
htmlparser.cpp chokes on the broken HTML forms from osnews and forgets which
form input element should refer to.
Comment 6 Christian Spitzlay 2005-11-21 07:25:06 UTC
Yes, that patch fixes the problem both with my local test case and the real world example.  Your speed is amazing. :) 

What will happen next?  
Comment 7 Allan Sandfeld 2006-01-13 11:10:56 UTC
SVN commit 497603 by carewolf:

Fix OSNews replies
BUG: 116790


 M  +5 -1      html_formimpl.cpp  


--- branches/KDE/3.5/kdelibs/khtml/html/html_formimpl.cpp #497602:497603
@@ -885,7 +885,11 @@
     {
         if( p->id() == ID_FORM )
             return static_cast<HTMLFormElementImpl *>(p);
-        p = p->parentNode();
+        NodeImpl *s = p->previousSibling();
+        if (!s)
+            p = p->parentNode();
+        else
+            p = s;
     }
 #ifdef FORMS_DEBUG
     kdDebug( 6030 ) << "couldn't find form!" << endl;
Comment 8 Ivor Hewitt 2006-03-09 16:00:05 UTC
SVN commit 517005 by ivor:

Replace one form reattach hack with another, pending a  better fix.

BUG: 122968
BUG: 122273
CCBUG: 116790



 M  +1 -5      html_formimpl.cpp  
 M  +9 -0      htmlparser.cpp  


--- branches/KDE/3.5/kdelibs/khtml/html/html_formimpl.cpp #517004:517005
@@ -886,11 +886,7 @@
     {
         if( p->id() == ID_FORM )
             return static_cast<HTMLFormElementImpl *>(p);
-        NodeImpl *s = p->previousSibling();
-        if (!s)
-            p = p->parentNode();
-        else
-            p = s;
+        p = p->parentNode();
     }
 #ifdef FORMS_DEBUG
     kdDebug( 6030 ) << "couldn't find form!" << endl;
--- branches/KDE/3.5/kdelibs/khtml/html/htmlparser.cpp #517004:517005
@@ -1388,6 +1388,15 @@
         blockElem->removeChild(currNode, exceptionCode);
         newNode->appendChild(currNode, exceptionCode);
         currNode = nextNode;
+
+ // TODO - To be replaced.
+        // Re-register form elements with currently active form, step 1 will have removed them
+        if (form)
+        {
+            HTMLGenericFormElementImpl *e = static_cast<HTMLGenericFormElementImpl *>(currNode);
+            if (e)
+                form->registerFormElement(e);
+        }
     }
 
     // Step 4: Place |newNode| under |blockElem|.  |blockElem| is still out of the document, so no
Comment 9 Christian Spitzlay 2006-06-19 02:44:02 UTC
It seems that the original bug is back.  :-(

The test cases still work, but the reference is lost again when posting on osnews.com.  

Tested with: 
Qt: 3.3.6
KDE: 3.5.3
Konqueror: 3.5.3

Comment 10 Allan Sandfeld 2006-06-19 11:43:24 UTC
The DOM is unchanged, and the test case show we send the hidden field...

It almost sounds like OSNews PHP code is breaking us.
Comment 11 Allan Sandfeld 2006-06-19 11:54:54 UTC
Created attachment 16693 [details]
Test case

This is the newest code from OSNews grapped today. Only thing changed is
changing form-action from post to get.

As demonstrated, Konqueror sends the ref value just fine. It must be OSNews
that specifically ignores the 'ref' when UA is Konqueror.
Comment 12 Allan Sandfeld 2006-06-19 12:03:14 UTC
Created attachment 16694 [details]
Patch

Ahh :) My original patch still works. Here's a modified version.
Comment 13 Christian Spitzlay 2006-06-19 22:28:39 UTC
Unfortunately I no longer have any svn version of the 3.5 branch around so I cannot test the patch.  

Will it make it into the next point release? 

Comment 14 Allan Sandfeld 2006-07-18 15:34:52 UTC
SVN commit 563771 by carewolf:

Fix for yet again broken replies in osnews.com. 
This implements the behavior on DOM level instead of at parsing. This also 
means that a reparsed DOM should work.
BUG: 116790


 M  +5 -0      html_formimpl.cpp  


--- branches/KDE/3.5/kdelibs/khtml/html/html_formimpl.cpp #563770:563771
@@ -890,6 +890,11 @@
     {
         if( p->id() == ID_FORM )
             return static_cast<HTMLFormElementImpl *>(p);
+        if( p->parentNode() && p->parentNode()->id() == ID_TABLE && p->previousSibling() )
+        {
+            p = p->previousSibling();
+            continue;
+        }
         p = p->parentNode();
     }
 #ifdef FORMS_DEBUG