Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

WEBrick serving files from /public produces routing error for files which have a "+" in their name #790

Closed
lighthouse-import opened this Issue May 16, 2011 · 2 comments

Comments

Projects
None yet
1 participant

Imported from Lighthouse. Original ticket at: http://rails.lighthouseapp.com/projects/8994/tickets/6185
Created by Andrew Dvorak - 2010-12-17 10:11:41 UTC

I have the following file: public/javascripts/jq+ui.min.js

When I attempt to view the file in my browser, rails generates an "Action Controller: Exception Caught; Routing Error; No route matches "/javascripts/jq+ui.min.js".

When I rename the file to: public/javascripts/jq-ui.min.js, the error is resolved and the file is served.

It rails apparently dislikes a "+" in the filename serving from public/

I am using Rails 3.0.3 ("development" environment), WEBrick 1.3.1, and Ruby 1.9.2 using RVM 1.1.3 on Ubuntu 10.10.

I've not tried it, but tests by others suggest that a setup using Apache is immune to this bug.

Imported from Lighthouse.
Comment by pnina - 2011-01-03 12:07:56 UTC

hi
i encountered the same problem
i just reinstall my computer and installed rails 3.0.3 and ruby 1.9.2 on windows 7 and WEBrick
when I open my application in the browser rails cannot find my JavaScript files and i am getting ActionController::routingError
I worked previously with rails 3.0 and all was fine

Imported from Lighthouse.
Comment by Andrew White - 2011-02-09 06:37:30 UTC

This is because the '+' is getting decoded as a space by Rack::Utils.unescape in ActionDispatch::Static and Rack::File. In production mode static file serving is handled by Apache so it works fine. Rack::Utils.unescape is very basic implementation in that it doesn't take into account the context of the + symbol which is allowed unescaped in paths but is treated as a space in query parameters.

This needs fixing in both places for it to work - URI.unescape (or URI::Parser.unescape in 1.9.2) would seem to provide the necessary method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment