rtomayko/rack-cache — Issue #47: invalid byte sequence in UTF-8 in Rack::Cache::Key
Author: tc
Created: 2012-01-12 01:49:47+00:00
State: open

I'm seeing a lot of these errors in our logs:

```
cache error: invalid byte sequence in UTF-8
/data/apps/production/web/shared/bundle/ruby/1.9.1/gems/rack-cache-1.1/lib/rack/cache/key.rb:46:in `split'
/data/apps/production/web/shared/bundle/ruby/1.9.1/gems/rack-cache-1.1/lib/rack/cache/key.rb:46:in `block in query_string'
/data/apps/production/web/shared/bundle/ruby/1.9.1/gems/rack-cache-1.1/lib/rack/cache/key.rb:45:in `map'
/data/apps/production/web/shared/bundle/ruby/1.9.1/gems/rack-cache-1.1/lib/rack/cache/key.rb:45:in `query_string'
```

```
def query_string
return nil if @request.query_string.nil?

@request.query_string.split(/[&;] */n).
46: map { |p| unescape(p).split('=', 2) }.
sort.
map { |k,v| "#{escape(k)}=#{escape(v)}" }.
join('&')
end
```