public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Search Repo:
Fix loading of arbitrary files in ruby's load path by 
traverse_to_controller.

git-svn-id: http://svn-commit.rubyonrails.org/rails/branches/stable@4456 
5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Nicholas Seckar (author)
Sat Jun 17 21:39:42 -0700 2006
commit  a12aabc450a0ff19dfc2238b6fec9fdb09f868be
tree    f4539f95660ca71146b7c1cb3322a85d9892faca
parent  bf150f0c3a250c1e1cc1f275b6ae98bb76827065
...
1
2
 
 
3
4
5
...
1
2
3
4
5
6
7
0
@@ -1,5 +1,7 @@
0
 *1.12.1* (April 6th, 2005)
0
 
0
+* (Hackish) Fix loading of arbitrary files in Ruby's load path by traverse_to_controller. [Nicholas Seckar]
0
+
0
 * Fixed that template extensions would be cached development mode #4624 [Stefan Kaes]
0
 
0
 * Update to Prototype 1.5.0_rc0 [Sam Stephenson]
...
245
246
247
248
249
250
251
252
253
 
 
 
 
 
 
 
 
 
 
 
254
 
255
256
257
...
245
246
247
 
 
 
 
 
 
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
0
@@ -245,13 +245,19 @@
0
               raise unless /^uninitialized constant .*#{controller_name}$/ =~ e.message
0
             end
0
             
0
- begin
0
- next_mod = eval("mod::#{mod_name}", nil, __FILE__, __LINE__)
0
- # Check that we didn't get a module from a parent namespace
0
- mod = (mod == Object || next_mod.name == "#{mod.name}::#{mod_name}") ? next_mod : nil
0
- rescue NameError => e
0
- raise unless /^uninitialized constant .*#{mod_name}$/ =~ e.message
0
+ if mod.const_defined? mod_name
0
+ next_mod = mod.send(:const_get, mod_name)
0
+ else
0
+ suffix = File.join(segments[start_at..index])
0
+ $:.each do |base|
0
+ path = File.join(base, suffix)
0
+ next unless File.directory? path
0
+ next_mod = Module.new
0
+ mod.send(:const_set, mod_name, next_mod)
0
+ break
0
+ end
0
             end
0
+ mod = next_mod
0
             
0
             return nil unless mod
0
           end
...
535
536
537
538
539
540
541
...
970
971
972
 
 
 
 
 
 
 
 
 
 
 
 
 
973
974
975
...
535
536
537
 
538
539
540
...
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
0
@@ -535,7 +535,6 @@
0
 
0
 class RouteTests < Test::Unit::TestCase
0
   
0
-
0
   def route(*args)
0
     @route = ::ActionController::Routing::Route.new(*args) unless args.empty?
0
     return @route
0
@@ -970,6 +969,19 @@
0
 
0
     assert_equal ['/journal', []], rs.generate(:controller => 'content', :action => 'list_journal', :date => nil, :user_id => nil)
0
   end
0
+end
0
+
0
+class ControllerComponentTest < Test::Unit::TestCase
0
+
0
+ def test_traverse_to_controller_should_not_load_arbitrary_files
0
+ load_path = $:.dup
0
+ base = File.dirname(File.dirname(File.expand_path(__FILE__)))
0
+ $: << File.join(base, 'fixtures')
0
+ assert_equal nil, ActionController::Routing::ControllerComponent.traverse_to_controller(%w(dont_load pretty please))
0
+ ensure
0
+ $:[0..-1] = load_path
0
+ end
0
+
0
 end
0
 
0
 end

Comments

    No one has commented yet.