braintree/braintree_ruby — pull request #19 by dougfales (2012-01-05 17:21:52+00:00)
Title: Fix for URL encoded parameters causing a bogus ForgedQueryString error

We noticed a problem where users whose query strings came back to us still url-encoded would cause a ForgedQueryString to occur. So for example, this type of query string was fine:

"http_status=200&id=8pqwmq2b459cxfkd&kind=create_customer&billing_credit_card_subscription[processor_plan_id]=solo_monthly&billing_credit_card_subscription[total_users]=1&hash=afd187d2f546d60f8faad923d6818aedc85e5a97"

Notice the square brackets are not url-encoded.

This type of request, on the other hand, would always fail:

"http_status=200&id=c287ttnpywp4y4jt&kind=create_customer&billing_credit_card_subscription%5Bprocessor_plan_id%5D=basic_monthly&billing_credit_card_subscription%5Btotal_users%5D=5&hash=13feede0d99a8d7480e27dc0c4fb754e8c2f5212"

Notice the square brackets *are* url-encoded in the failing case.

We're not sure why the parameters are coming back encoded in some cases and in others not--maybe browser differences or a proxy is re-writing them incorrectly.

At any rate, this patch adds a test case and always decodes the query string before re-hashing it.