Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Space and plus sign sent in POST (is it really a 1.7.1 bug?) #153

Closed
jwestbrook opened this issue Apr 22, 2014 · 2 comments
Closed

Space and plus sign sent in POST (is it really a 1.7.1 bug?) #153

jwestbrook opened this issue Apr 22, 2014 · 2 comments

Comments

@jwestbrook
Copy link
Collaborator

previous lighthouse ticket #1726
by red-fern


I noticed it's a new feature in 1.7.1 that encode all spaces to +'s.

The problem here is that what if I have a string "I have a dog + a cat + a parrot". It would be sent to the server as "I+have+a+dog+++a+cat+++a+parrot". My sever side has no idea which one is a space and which is a genuine plus sign.

I have created a test page on jsfiddle:

http://jsfiddle.net/2HJqM

that uses the latest prototype (1.7.1) and latest scriptaculous (1.9). When you go to my test page, fireup Firebug and active the Net tab. Click RUN, then enter "a + b + c", then click on the latest POST request that pops up in the Net tab. You should see on the POST tab: value: a+++b+++c.

What we expect to receive in the form submission is: a+%2B+b+%2B+c

@savetheclocktower
Copy link
Collaborator

I can see this happening in 1.7.1, but I get varying results in 1.7.2. Here's the same fiddle using 1.7.2 and scripty 1.9. In Chrome dev tools, your fiddle says the value is a+++b+++c, whereas on mine it says it's sending a + b + c. (Clicking the "view URL encoded" link shows what you'd expect.) Same with Safari.

In Firefox dev tools, both fiddles say they're sending a+++b+++c, but I suspect that's a bug in Firefox's dev tools. Therefore I'm inclined to close this and say it's fixed in 1.7.2. Anyone who has evidence that this is not yet fixed should feel free to reopen this bug.

@laurinkeithdavis
Copy link

Actually, we modified 1.7.1 a long time ago to fix this issue, by removing this line:

value = value.gsub(/%20/, '+'); *

From this:

serializeElements: function(elements, options){
    if(typeof options != 'object') options = { hash: !!options };
    else
        if(Object.isUndefined(options.hash)) options.hash = true;
    var key, value, submitted = false, submit = options.submit, accumulator, initial;

    if(options.hash){
        initial = {};
        accumulator = function(result, key, value){
            if(key in result){
                if(!Object.isArray(result[key])) result[key] = [result[key]];
                result[key].push(value);
            }else result[key] = value;
            return result;
        };
    }else{
        initial = '';
        accumulator = function(result, key, value){
            value = value.gsub(/(\r)?\n/, '\r\n');
            value = encodeURIComponent(value);
            //value = value.gsub(/%20/, '+'); *
            //BJR - 43987 - Client Dashboard - Change Name Adds "+" Signs
            return result + (result ? '&' : '') + encodeURIComponent(key) + '=' + value;
        }
    }

It was introduced in 1.7.1 and we've had no problems since removing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants