Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 3884

Show
Ignore:
Timestamp:
03/16/06 02:51:19 (3 years ago)
Author:
david
Message:

Dots in template path should not trip up rendering (closes #4244) [lmarlow@yahoo.com]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/lib/action_view/base.rb

    r3856 r3884  
    222222 
    223223      if use_full_path 
    224         template_path_without_extension, template_extension = template_path.split('.'
     224        template_path_without_extension, template_extension = path_and_extension(template_path
    225225 
    226226        if template_extension 
     
    336336 
    337337    def file_exists?(template_path)#:nodoc: 
    338       template_file_name, template_file_extension = template_path.split("."
     338      template_file_name, template_file_extension = path_and_extension(template_path
    339339       
    340340      if template_file_extension 
     
    360360        file_path = full_template_path(template_path, extension) 
    361361        @@method_names.has_key?(file_path) || FileTest.exists?(file_path) 
     362      end 
     363 
     364      def path_and_extension(template_path) 
     365        template_path_without_extension = template_path.sub(/\.(\w+)$/, '') 
     366        [ template_path_without_extension, $1 ] 
    362367      end 
    363368 
  • trunk/actionpack/test/controller/new_render_test.rb

    r3856 r3884  
    7474    render :file => 'test/render_file_with_ivar', :use_full_path => true 
    7575  end 
    76    
     76  
     77  def render_file_not_using_full_path_with_relative_path 
     78    @secret = 'in the sauce' 
     79    render :file => 'test/../test/render_file_with_ivar', :use_full_path => true 
     80  end 
     81   
     82  def render_file_not_using_full_path_with_dot_in_path 
     83    @secret = 'in the sauce' 
     84    render :file => 'test/dot.directory/render_file_with_ivar', :use_full_path => true 
     85  end 
     86 
    7787  def render_xml_hello 
    7888    @name = "David" 
     
    354364  end 
    355365 
     366  def test_render_file_not_using_full_path_with_relative_path 
     367    get :render_file_not_using_full_path_with_relative_path 
     368    assert_equal "The secret is in the sauce\n", @response.body 
     369  end 
     370 
     371  def test_render_file_not_using_full_path_with_dot_in_path 
     372    get :render_file_not_using_full_path_with_dot_in_path 
     373    assert_equal "The secret is in the sauce\n", @response.body 
     374  end 
     375 
    356376  def test_render_file_with_locals 
    357377    get :render_file_with_locals