preumich / oauth

Automatically exported from code.google.com/p/oauth
0 stars 0 forks source link

php lib: oAuth base string key/value sorting #72

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Looking at OAuth.php I noticed that keys and values (for duplicate keys)
are sorted using a "natural order" method for the base string.
See these lines (just search on "natsort"):
uksort($params, 'strnatcmp');
natsort($value);

Nowhere in the specification I found that this should be sorted in natural
order. Specification states 
"Parameters are sorted by name, using lexicographical byte value ordering."
See http://oauth.net/core/1.0/.

See a more detailed discussion on sorting here:
http://groups.google.com/group/oauth/browse_thread/thread/07c698004be0d536?pli=1
.

Again, nowhere "natural sorting" is mentioned. I recommend changing this to
regular sorting using:
uksort($params, 'strcmp');
sort($value);

Thanks

Original issue reported on code.google.com by tkoml...@gmail.com on 18 Dec 2008 at 9:06

GoogleCodeExporter commented 9 years ago

Original comment by leah.culver on 14 Jan 2009 at 10:02

GoogleCodeExporter commented 9 years ago
You appear to be correct. I am responsible for the choice of natsort, because 
it was better than the way it was 
prior to that, and it appeared correct at the time (it didn't fail any of the 
test-cases)..

I have tried changing to strcmp, and this too passes all test-cases and 
actually follows the specs. So the attached 
patch is merely a formal patch that changes to using strcmp and I recommend 
that we add it...

Original comment by morten.f...@gmail.com on 28 Jan 2009 at 1:54

Attachments: