Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #7806 (closed defect: fixed)

Opened 2 years ago

Last modified 2 years ago

AJAX parameters without value get dropped

Reported by: renggli Assigned to: sam
Priority: high Milestone: 1.x
Component: Prototype Version: edge
Severity: major Keywords: 1.5.1_rc1
Cc:

Description

Ajax.Request.prototype clones the request parameters in the function request(url). It did not do so in previous versions.

This change causes parameters to be dropped that consist only of a key (and no value). For example, a parameter string like 'a=1&b' gets converted to 'a=1' (the b is dropped).

Change History

03/12/07 20:29:14 changed by renggli

Sorry, my conclusion of this bug was completely wrong. The actual cause is the function Hash.toQueryString.addPair that ignores pairs with value == null. I suggest to remove line 793 to get:

Hash.toQueryString.addPair = function(key, value, prefix) {
	key = encodeURIComponent(key);
	this.push(key + '=' + (value == null ? '' : encodeURIComponent(value)))
}

03/15/07 23:30:13 changed by amattie

  • priority changed from normal to high.

Similarly, this is a fairly large problem when the parameters are passed as a string. Line 960 runs .toQueryParams() on the string, and this causes a problem for empty parameters on line 293 as the value in the key / value pair when split is actually undefined. Ultimately, this problem leads to blank values in a string of parameters being excluded from the AJAX request and causes significant heartache for webservices that expect the parameter to be passed even with a blank value.

03/21/07 19:27:38 changed by bokuhog

see also
* Ticket #7882

03/27/07 20:56:33 changed by madrobby

  • status changed from new to closed.
  • resolution set to fixed.

Fixed in [6481].