Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

Parse PUT data

#57

When you send data in POST like: user[name]=myname&user[pass]=mypass, the corresponding data is interpreted correcly:

[post] => Array

            (
                [user] => Array
                    (
                        [name] => myname
                        [pass] => mypass
                    )

            )

But, when my form sends the same content as PUT, the data is interpreted as: [put] => Array

            (
                [cliente[name]] => myname
                [cliente[pass]] => mypass
            )

So, i've changed the file 'lib/recess/http/Environment.class.php', method getPutParameters from:

private static function getPutParameters() {

    $putdata = file_get_contents('php://input');
    return QueryString::parse($putdata);

}

to:

private static function getPutParameters() {

    $putdata = file_get_contents('php://input');
    // FIX: Parse PUT data correctly as POST does ;)
    mb_parse_str($putdata, $outputdata);
    return $outputdata;     

}

Please Kris, check if i am correct!

LZ

Reported by Luiz Alberto Zaiats · January 27th, 2009 @ 11:03 PM

State: resolved
Milestone: 0.11.1
Assigned to: Kris Jordan Kris Jordan

Activity

  1. Kris Jordan
    Kris Jordan
    • State changed from new to open

    This does indeed look correct. Great find and thanks for a fix. My only concern is for folks without the mb extension installed. Will look into a solution for those without the multibyte string extension turned on.

    February 4th, 2009 @ 05:38 PM

  2. Kris Jordan
    Kris Jordan
    • State changed from open to resolved

    Thank-you for the suggested changes! This has been added into Recess Edge on GitHub with the changes suggested (actual code below).

    
    $putdata = file_get_contents('php://input');
    if(function_exists('mb_parse_str')) {
        	mb_parse_str($putdata, $outputdata);
    } else {
    	parse_str($putdata, $outputdata);
    }
    

    February 16th, 2009 @ 03:49 PM

  3. Kris Jordan
    Kris Jordan

    Also, the Git commit signature is 5c234f6!

    February 16th, 2009 @ 03:50 PM

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.