Browse files

Regexp.escape(load_path) in add_routing_namespaces initializer [#4442


Signed-off-by: Michael Koziarski <>
  • Loading branch information...
1 parent 69bd542 commit d03196c89e92e9b3aa553bf5f7a9bcb23c955025 @phs phs committed with NZKoz Apr 19, 2010
Showing with 1 addition and 1 deletion.
  1. +1 −1 railties/lib/rails/engine.rb
@@ -166,7 +166,7 @@ def load_tasks do |load_path|
load_path = File.expand_path(load_path)
Dir["#{load_path}/*/**/*_controller.rb"].collect do |path|
- namespace = File.dirname(path).sub(/#{load_path}\/?/, '')
+ namespace = File.dirname(path).sub(/#{Regexp.escape(load_path)}\/?/, '')
app.routes.controller_namespaces << namespace unless namespace.empty?

2 comments on commit d03196c

radar commented on d03196c Apr 19, 2010

Shouldn't this have been tested to ensure a regression wouldn't happen?

phs commented on d03196c Apr 19, 2010

I didn't find any tests involving the string "controller_namespaces". If you point me at an appropriate suite, (which hopefully knows how to run enough of the rails boot sequence to hit this initializer) I'll make a test. Alternately we could pull the initializer's contents out to somewhere more testable, but I don't trust myself yet to do that refactoring properly.

Please sign in to comment.