Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

…state:resolved]

Signed-off-by: Michael Koziarski <michael@koziarski.com>
  • Loading branch information...
commit d03196c89e92e9b3aa553bf5f7a9bcb23c955025 1 parent 69bd542
@phs phs authored NZKoz committed
Showing with 1 addition and 1 deletion.
  1. +1 −1  railties/lib/rails/engine.rb
View
2  railties/lib/rails/engine.rb
@@ -166,7 +166,7 @@ def load_tasks
paths.app.controllers.to_a.each 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?
end
end

2 comments on commit d03196c

@radar

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

@phs

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.
Something went wrong with that request. Please try again.