Skip to content
This repository
Browse code

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
Phil Smith authored April 19, 2010 NZKoz committed April 20, 2010

Showing 1 changed file with 1 addition and 1 deletion. Show diff stats Hide diff stats

  1. 2  railties/lib/rails/engine.rb
2  railties/lib/rails/engine.rb
@@ -166,7 +166,7 @@ def load_tasks
166 166
       paths.app.controllers.to_a.each do |load_path|
167 167
         load_path = File.expand_path(load_path)
168 168
         Dir["#{load_path}/*/**/*_controller.rb"].collect do |path|
169  
-          namespace = File.dirname(path).sub(/#{load_path}\/?/, '')
  169
+          namespace = File.dirname(path).sub(/#{Regexp.escape(load_path)}\/?/, '')
170 170
           app.routes.controller_namespaces << namespace unless namespace.empty?
171 171
         end
172 172
       end

2 notes on commit d03196c

Ryan Bigg

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

Phil Smith
phs commented on d03196c April 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.
Something went wrong with that request. Please try again.