zanker/ruby-smugmug — pull request #3 by lylo (2014-04-16 21:53:03+00:00)
Title: More comprehensive url escaping

I found issues with `GCI::escape` when creating Smugmug albums via the API. I traced it back to albums that had spaces and commas in their name. These albums failed to create and I'd get a `#35 signature error` back from the API. I traced this back to the escaping in the `HTTP` class. This pull request addresses this issue.

Here's an example:

````ruby
require 'cgi'
CGI::escape('Hello, World.')
=> "Hello%2C+World."
````
The `+` in the escaped string is not correctly escaped. It should be `%20` as per the spec. `URI::escape` corrects this, but it doesn't escape commas by default:

````ruby
URI::escape('Hello, World.')
=> "Hello,%20World."
````
In order to fix this, you can pass in the correct regex for `URI::escape` to use, which is what I've done on this PR.

````ruby
URI::escape('Hello, World.', Regexp.new("[^#{URI::REGEXP::PATTERN::UNRESERVED}]", false, 'N'))
=> "Hello%2C%20World."
````