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

Ticket #8548 (closed defect: fixed)

Opened 2 years ago

Last modified 2 years ago

Hash.toQueryString improperly double-encodes array values

Reported by: richardtallent Assigned to: sam
Priority: normal Milestone: 1.x
Component: Prototype Version: edge
Severity: normal Keywords: serialize encodeURIComponent field checkbox array element form
Cc:

Description

I noticed that, when *multiple* checkboxes on a form are selected, calls to Form.serialize() result in the values being double-escaped. For example, instead of "&myusers=John%20Doe&myusers=Sally%20Smith", I would get "&myusers=John%2520Doe&myusers=Sally%2520Smith".

I traced this back to lines 649 and 650 in Prototype 1.5.0, which is called when serializing an array of values:

value = value != undefined ? encodeURIComponent(value) : ; parts.push(key + '=' + encodeURIComponent(value));

The extra call to encodeURIComponent() should be removed from the second statement.

Change History

06/01/07 18:39:51 changed by richardtallent

Apparently the wiki-formatting ate the empty string literal in the first line, switched to italics, and combined the lines of code.

The part beginning "parts.push(...)" is the offending line of code.

06/01/07 18:52:45 changed by richardtallent

Please mark dead, this has been fixed in 1.5.1. Just realized I'm out of date.

06/02/07 05:03:10 changed by Tobie

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