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

Changeset 7724

Show
Ignore:
Timestamp:
10/03/07 05:47:41 (1 year ago)
Author:
rick
Message:

Move ActionController::Routing.optimise_named_routes to ActionController::Base.optimise_named_routes. Now you can set it in the config.
ActionController::Routing::DynamicSegment#interpolation_chunk should call #to_s on all values before calling URI.escape. [Rick]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/CHANGELOG

    r7722 r7724  
    11*SVN* 
     2 
     3* Move ActionController::Routing.optimise_named_routes to ActionController::Base.optimise_named_routes.  Now you can set it in the config. [Rick] 
     4 
     5  config.action_controller.optimise_named_routes = false 
     6 
     7* ActionController::Routing::DynamicSegment#interpolation_chunk should call #to_s on all values before calling URI.escape.  [Rick] 
    28 
    39* Only accept session ids from cookies, prevents session fixation attacks.  [bradediger]  
  • trunk/actionpack/lib/action_controller/base.rb

    r7719 r7724  
    330330    # Sets the token parameter name for RequestForgery.  Calling #protect_from_forgery sets it to :authenticity_token by default 
    331331    cattr_accessor :request_forgery_protection_token 
    332      
     332 
     333    # Indicates whether or not optimise the generated named 
     334    # route helper methods 
     335    cattr_accessor :optimise_named_routes 
     336    self.optimise_named_routes = true 
     337 
    333338    # Controls whether request forgergy protection is turned on or not. Turned off by default only in test mode. 
    334339    class_inheritable_accessor :allow_forgery_protection 
  • trunk/actionpack/lib/action_controller/integration.rb

    r7719 r7724  
    7777          # But we have to disable the optimisation code so that we can 
    7878          # generate routes without @request being initialized 
    79           Routing.optimise_named_routes=false 
     79          Base.optimise_named_routes=false 
    8080          Routing::Routes.reload! 
    8181          klass = class<<self; self; end 
  • trunk/actionpack/lib/action_controller/routing.rb

    r7719 r7724  
    256256    mattr_accessor :controller_paths 
    257257    self.controller_paths = [] 
    258      
    259     # Indicates whether or not optimise the generated named 
    260     # route helper methods 
    261     mattr_accessor :optimise_named_routes 
    262     self.optimise_named_routes = true 
    263258     
    264259    # A helper module to hold URL related helpers. 
     
    343338      # version of the named routes methods. 
    344339      def optimise? 
    345         @optimise && ActionController::Routing::optimise_named_routes 
     340        @optimise && ActionController::Base::optimise_named_routes 
    346341      end 
    347342       
     
    719714      end 
    720715   
    721       def interpolation_chunk(value_code = "#{local_name}.to_s") 
    722         "\#{URI.escape(#{value_code}, ActionController::Routing::Segment::UNSAFE_PCHAR)}" 
     716      def interpolation_chunk(value_code = "#{local_name}") 
     717        "\#{URI.escape(#{value_code}.to_s, ActionController::Routing::Segment::UNSAFE_PCHAR)}" 
    723718      end 
    724719   
     
    777772 
    778773      # Don't URI.escape the controller name since it may contain slashes. 
    779       def interpolation_chunk(value_code = "#{local_name}.to_s") 
    780         "\#{#{value_code}}" 
     774      def interpolation_chunk(value_code = "#{local_name}") 
     775        "\#{#{value_code}.to_s}" 
    781776      end 
    782777 
     
    800795      UNSAFE_PCHAR = Regexp.new("[^#{URI::REGEXP::PATTERN::UNRESERVED}#{RESERVED_PCHAR}]", false, 'N').freeze 
    801796 
    802       def interpolation_chunk(value_code = "#{local_name}.to_s") 
    803         "\#{URI.escape(#{value_code}, ActionController::Routing::PathSegment::UNSAFE_PCHAR)}" 
     797      def interpolation_chunk(value_code = "#{local_name}") 
     798        "\#{URI.escape(#{value_code}.to_s, ActionController::Routing::PathSegment::UNSAFE_PCHAR)}" 
    804799      end 
    805800 
  • trunk/actionpack/test/controller/resources_test.rb

    r7447 r7724  
    3434  # optimisation.  This could indicate user level problems 
    3535  def setup 
    36     ActionController::Routing.optimise_named_routes = false 
     36    ActionController::Base.optimise_named_routes = false 
    3737  end 
    3838   
    3939  def tear_down 
    40     ActionController::Routing.optimise_named_routes = true 
     40    ActionController::Base.optimise_named_routes = true 
    4141  end 
    4242   
  • trunk/actionpack/test/controller/routing_test.rb

    r7673 r7724  
    4949  def setup 
    5050    # These tests assume optimisation is on, so re-enable it. 
    51     ActionController::Routing.optimise_named_routes = true 
     51    ActionController::Base.optimise_named_routes = true 
    5252 
    5353    @rs = ::ActionController::Routing::RouteSet.new 
     
    853853  end 
    854854   
     855  def test_interpolation_chunk_should_accept_nil 
     856    a_value = nil 
     857    assert_equal '', eval(%("#{segment.interpolation_chunk('a_value')}")) 
     858  end 
     859   
    855860  def test_value_regexp_should_be_nil_without_regexp 
    856861    assert_equal nil, segment.value_regexp