diff --git a/CHANGELOG.md b/CHANGELOG.md index 6366a4d92..819b7defe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ **Master** +- Preserve literal plus signs when decoding asset request paths. [Oskar Eichler](https://github.com/OskarEichler) + Get upgrade notes from Sprockets 3.x to 4.x at https://github.com/rails/sprockets/blob/master/UPGRADING.md # 4.4.1 diff --git a/README.md b/README.md index 958b44cd4..a3e14d83a 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,8 @@ If you want to work on Sprockets or better understand how it works read [How Spr ## Behavior Overview +The asset server decodes request paths as URI paths: a literal `+` stays a plus sign, while `%20` denotes a space. + You can interact with Sprockets primarily through directives and file extensions. This section covers how to use each of these things, and the defaults that ship with Sprockets. Since you are likely using Sprockets through another framework (such as the [Rails asset pipeline](http://guides.rubyonrails.org/asset_pipeline.html)), there will be configuration options you can toggle that will change behavior such as what directories or files get compiled. For that documentation you should see your framework's documentation. diff --git a/lib/sprockets/server.rb b/lib/sprockets/server.rb index c32ce2228..501089eb1 100644 --- a/lib/sprockets/server.rb +++ b/lib/sprockets/server.rb @@ -45,7 +45,7 @@ def call(env) msg = "Served asset #{env['PATH_INFO']} -" # Extract the path from everything after the leading slash - full_path = Rack::Utils.unescape(env['PATH_INFO'].to_s.sub(/^\//, '')) + full_path = Rack::Utils.unescape_path(env['PATH_INFO'].to_s.sub(/^\//, '')).force_encoding(Encoding::UTF_8) path = full_path unless path.valid_encoding?