campaignmonitor/createsend-perl — pull request #9 by spacebat (2013-04-02 04:39:19+00:00)
Title: Fix for URI escaping bug

Hi, I've run into a bug where several of our subscribers could be bulk imported but every attempt to operate on them individually gave bad request 400 errors. They all had plus '+' signs in their email addresses, when being operated on individually the email address provided to the API as a query parameter and URI::Escape was only being used for authentication, not for any other request. However the API naturally requires all such parameters to be URI escaped.

Rather than build requests by string concatenation and remembering to splice in calls to uri_escape in all the right places, I wrote private methods _build_request and _rest which accept data structures describing the request and build the request using the URI module.

Along the way I tidied up some of the method parameter handling to make it clearer from the source how parameters are to be supplied.

In order to test this I just added "+stuff" to email addresses in 02_account.t and 06_subscribers.t so that these objects are initially created with email addresses requiring URI escaping and are subsequently updated to not have the "+stuff".

I hope the change is not too big, but it does fix a pretty significant bug in the module.