sporkmonger/addressable — pull request #146 by timcraft (2013-11-02 20:34:11+00:00)
Title: Fix character class bug/warnings

Starting at the top, here is a relatively minimal example which demonstrates the issue:

```ruby
require 'addressable/uri'

uri = Addressable::URI.parse('http://httpbin.org/get?a=1&b=2')
uri.normalize
```

Running that with `-W2` results in 2 "character class has duplicated range" warnings. Remove one of the query string parameters and the warnings disappear.

Looking at the code, this is because `normalized_query` calls `Addressable::URI.normalize_component` with a third argument (uri.rb#L1468). This triggers a conditional which results in a destructive change to the character_class argument, uri.rb#L508. The following lower level example shows the duplicated percent character:

```ruby
require 'addressable/uri'

character_class = Addressable::URI::CharacterClasses::QUERY

Addressable::URI.normalize_component('xxx', character_class, '+')
Addressable::URI.normalize_component('xxx', character_class, '+')

p character_class
```

It doesn't make much sense to spec that this shouldn't happen, and there might be a better fix, but this hopefully is sufficient to highlight/demonstrate the problem.