Skip to content

[BUG] Invalid POSTfields parsing in RequestParser #44

Closed

Description

@greevex

There some bug in a postfields parsing in file
https://github.com/reactphp/http/blob/master/src/RequestParser.php#L138

Need to replace

parse_str(urldecode($content), $result);

with

parse_str($content, $result);

Example:

// example postfields
$data = [
    'url' => 'http://somedomain/?field1=v1&field2=v2',
    'flag' => 1
];

$string = http_build_query($data);
// encoded to post body as
// url=http%3A%2F%2Fsomedomain%2F%3Ffield1%3Dv1%26field2%3Dv2&flag=1

// So, right way to parse
$result = null;
parse_str($string, $result);
var_dump($result);

array(2) {
  'url' =>
  string(38) "http://somedomain/?field1=v1&field2=v2"
  'flag' =>
  string(1) "1"
}

// and wrong way to parse
$result = null;
parse_str(urldecode($string), $result);
var_dump($result);

array(3) {
  'url' =>
  string(28) "http://somedomain/?field1=v1"
  'field2' =>
  string(2) "v2"
  'flag' =>
  string(1) "1"
}

Activity

  1. added a commit that references this issue on Oct 20, 2015
    7c52e53
  2. greevex commented on Oct 28, 2015

    @greevex
    ContributorAuthor

    Is there any alive owners here?

  3. added a commit that references this issue on Oct 28, 2015
    0c19a24
  4. WyriHaximus commented on Oct 28, 2015

    @WyriHaximus
    Member

    Yes although we might not always respond quickly. Thanks for the bug report and PR, currently I'm in the middle of refactoring the request parsing #41 and I'll make sure this bug won't slip back in through that

  5. greevex commented on Oct 28, 2015

    @greevex
    ContributorAuthor

    @WyriHaximus Thank you! We use this library in few projects and it's awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions