Opened 15 years ago

Closed 14 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: [email protected]
Blocked By: Blocking:


Posting the following form:

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

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


Results in the following raw post data:


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;
                        var form = dojo.byId(args.form);
                        ioArgs.url = args.url || form.getAttribute("action");
-                       formQuery = dojo.formToQuery(form);
+                       formObject = dojo.formToObject(form);
                        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);
                        // stuff in content over-rides what's set by form

Attachments (1)

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

Download all attachments as: .zip

Change History (5)

comment:1 Changed 15 years ago by guest

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

Changed 15 years ago by guest

Attachment: xhr.diff added

also fixes queryToString() decoding

comment:2 Changed 15 years ago by tk

Cc: [email protected] added

comment:3 Changed 14 years ago by James Burke

Milestone: 0.9

May try for 0.9, but may push to 1.0.

comment:4 Changed 14 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.