Bug 122968

Summary: [Test Case] Input fields outside forms are submitted
Product: [Applications] konqueror Reporter: Jörg Afflerbach <nospam>
Component: khtml formsAssignee: Konqueror Developers <konq-bugs>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed In:

Description Jörg Afflerbach 2006-03-02 13:11:43 UTC
Version:            (using KDE KDE 3.5.1)
Installed from:    SuSE RPMs
OS:                Linux

Konqueror submits form elements which are outside of forms, which IMHO it should not.
See test case below: Element "B" should not be submitted.

This actually did work in KDE 3.5.0. It also works in Firefox, Safari and MSIE.

---------------------------------------------------------------------

<?xml version="1.0" encoding="ISO-8859-15"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Form Test</title>
    </head>

    <body>
        <form action="#">
            <fieldset>
                <input type="text" name="A" value="visible"/>
                <input type="submit"/>
            </fieldset>
        </form>

        <div style="display: none">
            <!-- This form element is outside the form and should therefore not be
                 submitted. -->
            <input type="text" name="B" value="hidden"/>
        </div>
    </body>
</html>
Comment 1 Ivor Hewitt 2006-03-09 16:00:06 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