idangazit/oauthlib — pull request #21 by calebbrown (2012-04-19 04:14:37+00:00)
Title: Better handle unicode in OAuth1's parameter parsing.

### Problem

The problem I was having was that `oauth1.rfc5849.signature.collect_parameters()` was not properly supporting headers that were in unicode.

This problem doesn't expose itself unless you pass through parameters that will change when escaped/unescaped, e.g URLs.

The problem can be seen in `Client.sign()`. What happens is `oauth1.rfc5849.parameters.prepare_headers()` is called (via `Client._contribute_parameters()`), builds *and* escapes the headers and returns a unicode encoded header string.

This is then passed to `signature.collect_parameters()` (via `Client.get_oauth_signature()`) which fails to unescape the headers because they're in unicode.

The base string is then built from these, leading to an incorrect signature being generated.

### Solution

My implementation solves the problem by allowing both unicode and str types to be unescaped in `signature.collect_parameters()`.

The fix is in the last two changesets.

This pull requests also includes everything from my [last pull request](https://github.com/idangazit/oauthlib/pull/20) (if I had planned it better they would've all been in separate branches :/)