PHP Classes

Bug on line 1263 and 1264 in oauth_client.php, v1.66

Recommend this page to a friend!

      PHP OAuth Library  >  All threads  >  Bug on line 1263 and 1264 in...  >  (Un) Subscribe thread alerts  
Subject:Bug on line 1263 and 1264 in...
Summary:Incorrect parsing of server response
Messages:2
Author:John Erck
Date:2013-07-12 18:10:19
Update:2013-07-13 04:30:29
 

  1. Bug on line 1263 and 1264 in...   Reply   Report abuse  
Picture of John Erck John Erck - 2013-07-12 18:10:19
Hi Manuel,

I found a bug on line 1263 and 1264 in oauth_client.php, v1.66 that results in the incorrect parsing of the server's response.

The following server response 'Content-Type' values: 'text/plain' (line 1263) and 'text/html' (line 1264) are both being parsed with parse_str (http://php.net/manual/en/function.parse-str.php) which is designed to parse URL query string arguments (query string format example: "first=value&arr[]=foo+bar&arr[]=baz").

'text/plain' and 'text/html' do not match the URL query string format parse_str expects.

'text/plain' should fall through to the switch's default (i.e. return the string unparsed). 'text/html' should either also fall through to the switch's default or maybe be parsed as html using PHP's DOM (http://www.php.net/manual/en/book.dom.php).

Commenting out lines 1263 and 1264 did the trick for me. Now when I var_dump($response) from callAPI(/*args*/, $response) I get a nice readable string from 'text/plain' server responses rather than an array with garbled content.

Your OAuth Client package is awesome. Hope this helps improve it. Thanks.

  2. Re: Bug on line 1263 and 1264 in...   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2013-07-13 04:30:29 - In reply to message 1 from John Erck
The problem is that some servers return application/x-www-form-urlencoded response but the content type header is set to text/plain or text/html.

It is not right but if the class does not process those responses as application/x-www-form-urlencoded applications that rely on decoded responses will break.

If you want to make the class not try to decode any response data, just set the ResponseContentType parameters to application/octet-stream which is for binary data.