```ruby
# -*- encoding: utf-8 -*-
require 'spec_helper'

describe 'UTF8Cleaner::Middleware' do
  let :env do
    {
      'PATH_INFO' => 'foo/bar%2e%2fbaz',
      'QUERY_STRING' => 'foo=bar%FF',
      'HTTP_REFERER' => 'http://example.com/blog+Result:+%ED%E5+%ED%E0%F8%EB%EE%F1%FC+%F4%EE%F0%EC%FB+%E4%EB%FF+%EE%F2%EF%F0%E0%E2%EA%E8',
      'REQUEST_URI' => '%C3%89'
    }
  end

  let :new_env do
    UTF8Cleaner::Middleware.new(nil).send(:sanitize_env, env)
  end

  it "removes invalid UTF-8 sequences" do
    new_env['QUERY_STRING'].should == 'foo=bar'
  end

  it "turns valid %-escaped ASCII chars into their ASCII equivalents" do
    new_env['PATH_INFO'].should == 'foo/bar./baz'
  end

  it "leaves valid %-escaped UTF-8 chars alone" do
    new_env['REQUEST_URI'].should == '%C3%89'
  end

  it "handles an awful URL" do
    new_env['HTTP_REFERER'].should == 'http://example.com/blog+Result:+++++'
  end
  
  it "reencodes ampersands and semicolons" do
    result = UTF8Cleaner::Middleware.new(nil).send(:sanitize_env, env.merge('QUERY_STRING' => 'foo%26bar%3Bbaz'))
    result['QUERY_STRING'].should == 'foo%26bar%3Bbaz'
  end
end```

Revise specs to provide guidelines for conservative behavior
user
```ruby
# -*- encoding: utf-8 -*-
require 'spec_helper'

describe 'UTF8Cleaner::Middleware' do
  let :env do
    {
      'PATH_INFO' => 'foo/%FFbar%2e%2fbaz%26%3B',
      'QUERY_STRING' => 'foo=bar%FF',
      'HTTP_REFERER' => 'http://example.com/blog+Result:+%ED%E5+%ED%E0%F8%EB%EE%F1%FC+%F4%EE%F0%EC%FB+%E4%EB%FF+%EE%F2%EF%F0%E0%E2%EA%E8',
      'REQUEST_URI' => '%C3%89%E2%9C%93'
    }
  end

  let :new_env do
    UTF8Cleaner::Middleware.new(nil).send(:sanitize_env, env)
  end

  describe "removes invalid UTF-8 sequences" do
    it { new_env['QUERY_STRING'].should == 'foo=bar' }
    it { new_env['HTTP_REFERER'].should == 'http://example.com/blog+Result:+++++' }
  end

  describe "leaves all valid characters untouched" do
    it { new_env['PATH_INFO'].should == 'foo/bar%2e%2fbaz%26%3B' }
    it { new_env['REQUEST_URI'].should == '%C3%89%E2%9C%93' }
  end
end```
assistant