#57 ✓resolved
Luiz Alberto Zaiats

Parse PUT data

Reported by Luiz Alberto Zaiats | January 27th, 2009 @ 11:03 PM | in 0.11.1

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

Comments and changes to this ticket

  • Kris Jordan

    Kris Jordan February 4th, 2009 @ 05:38 PM

    • 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.

  • Kris Jordan

    Kris Jordan February 16th, 2009 @ 03:49 PM

    • 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);
    }
    
  • Kris Jordan

    Kris Jordan February 16th, 2009 @ 03:50 PM

    Also, the Git commit signature is 5c234f6!

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.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

The Recess PHP Framework is an open source, full stack, RESTful PHP framework.

http://www.recessframework.org/

People watching this ticket

Pages