Opened 12 years ago

Closed 12 years ago

#3845 closed defect (fixed)

xhrPost() double-escapes form field names

Reported by: guest Owned by: James Burke
Priority: high Milestone: 0.9
Component: IO Version: 0.9
Keywords: Cc: matt@…
Blocked By: Blocking:

Description

Posting the following form:

<form onsubmit="dojo.xhrPost({'form' : this})">

<input type="text" name="test[1]" value="first" /> <input type="submit" value="submit" />

</form>

Results in the following raw post data:

array%255B1%255D=first

The '[' has been escaped twice - first to '%5B', then the '%' gets escaped again.

dojo._ioSetArgs() turns the form into an object, the object into a string, the string back into an object and then the object into a string. Below is a simple patch that seems to address the problem - I'd attach it, but can't see how :

--- xhr.js.orig 2007-07-24 16:33:00.000000000 +0100
+++ xhr.js      2007-07-24 16:33:52.000000000 +0100
@@ -271,11 +271,11 @@
                ioArgs.args = args;
 
                //Get values from form if requestd.
-               var formQuery = null;
+               var formObject = null;
                if(args.form){
                        var form = dojo.byId(args.form);
                        ioArgs.url = args.url || form.getAttribute("action");
-                       formQuery = dojo.formToQuery(form);
+                       formObject = dojo.formToObject(form);
                }else{
                        ioArgs.url = args.url;
                }
@@ -283,9 +283,9 @@
                // set up the query params
                var miArgs = [{}];
 
-               if(formQuery){
+               if(formObject){
                        // potentially over-ride url-provided params w/ form values
-                       miArgs.push(dojo.queryToObject(formQuery));
+                       miArgs.push(formObject);
                }
                if(args.content){
                        // stuff in content over-rides what's set by form

Attachments (1)

xhr.diff (1.1 KB) - added by guest 12 years ago.
also fixes queryToString() decoding

Download all attachments as: .zip

Change History (5)

comment:1 Changed 12 years ago by guest

Ok, worked out the attachment business. Now how do I get CC'd on this issue? Grrr...

Changed 12 years ago by guest

Attachment: xhr.diff added

also fixes queryToString() decoding

comment:2 Changed 12 years ago by tk

Cc: matt@… added

comment:3 Changed 12 years ago by James Burke

Milestone: 0.9

May try for 0.9, but may push to 1.0.

comment:4 Changed 12 years ago by James Burke

Resolution: fixed
Status: newclosed

(In [10205]) Fixes #3845. Needless double transform of form info, but also pointed to an issue with dojo.queryToObject, it was not calling decodeURIComponent for the query names. Fixed that too.

Note: See TracTickets for help on using tickets.