Development

Changeset 20472

You must first sign up to be able to contribute.

Changeset 20472

Show
Ignore:
Timestamp:
07/24/09 21:25:20 (4 years ago)
Author:
Kris.Wallsmith
Message:

[1.2, 1.3] Fixed case-insensitive check of sf_method routing requirement.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.2/lib/routing/sfRequestRoute.class.php

    r20469 r20472  
    3434      $requirements['sf_method'] = array('get', 'head'); 
    3535    } 
    36     else if (!is_array($requirements['sf_method'])) 
     36    else 
    3737    { 
    38       $requirements['sf_method'] = array($requirements['sf_method']); 
     38      $requirements['sf_method'] = array_map('strtolower', (array) $requirements['sf_method']); 
    3939    } 
    4040 
     
    5858 
    5959    // enforce the sf_method requirement 
    60     foreach ($this->requirements['sf_method'] as $method
     60    if (in_array(strtolower($context['method']), $this->requirements['sf_method'])
    6161    { 
    62       if (0 == strcasecmp($method, $context['method'])) 
    63       { 
    64         return $parameters; 
    65       } 
     62      return $parameters; 
    6663    } 
    6764 
     
    7067 
    7168  /** 
    72    * Returns true if the parameters matches this route, false otherwise. 
     69   * Returns true if the parameters match this route, false otherwise. 
    7370   * 
    7471   * @param  mixed   $params The parameters 
     
    8279    { 
    8380      // enforce the sf_method requirement 
    84       if (!in_array($params['sf_method'], $this->requirements['sf_method'])) 
     81      if (!in_array(strtolower($params['sf_method']), $this->requirements['sf_method'])) 
    8582      { 
    8683        return false; 
  • branches/1.2/test/unit/routing/sfRequestRouteTest.php

    r20469 r20472  
    1111require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
    1212 
    13 $t = new lime_test(4, new lime_output_color()); 
     13$t = new lime_test(8, new lime_output_color()); 
    1414 
    1515// ->__construct() 
     
    3333$route = new sfRequestRoute('/', array(), array('sf_method' => array('get', 'head'))); 
    3434$t->ok($route->matchesParameters(array('sf_method' => 'get')), '->matchesParameters() matches the "sf_method" parameter'); 
     35 
     36$route = new sfRequestRoute('/', array(), array('sf_method' => array('get'))); 
     37$t->ok($route->matchesParameters(array('sf_method' => 'GET')), '->matchesParameters() checks "sf_method" requirement case-insensitively'); 
     38 
     39$route = new sfRequestRoute('/', array(), array('sf_method' => array('GET'))); 
     40$t->ok($route->matchesParameters(array('sf_method' => 'get')), '->matchesParameters() checks "sf_method" requirement case-insensitively'); 
     41 
     42// ->matchesUrl() 
     43$t->diag('->matchesUrl()'); 
     44 
     45$route = new sfRequestRoute('/', array(), array('sf_method' => 'GET')); 
     46$t->isa_ok($route->matchesUrl('/', array('method' => 'get')), 'array', '->matchesUrl() check "sf_method" requirement case-insensitively'); 
     47 
     48$route = new sfRequestRoute('/', array(), array('sf_method' => 'get')); 
     49$t->isa_ok($route->matchesUrl('/', array('method' => 'GET')), 'array', '->matchesUrl() check "sf_method" requirement case-insensitively'); 
  • branches/1.3/lib/routing/sfRequestRoute.class.php

    r20469 r20472  
    3434      $requirements['sf_method'] = array('get', 'head'); 
    3535    } 
    36     else if (!is_array($requirements['sf_method'])) 
     36    else 
    3737    { 
    38       $requirements['sf_method'] = array($requirements['sf_method']); 
     38      $requirements['sf_method'] = array_map('strtolower', (array) $requirements['sf_method']); 
    3939    } 
    4040 
     
    5858 
    5959    // enforce the sf_method requirement 
    60     foreach ($this->requirements['sf_method'] as $method
     60    if (in_array(strtolower($context['method']), $this->requirements['sf_method'])
    6161    { 
    62       if (0 == strcasecmp($method, $context['method'])) 
    63       { 
    64         return $parameters; 
    65       } 
     62      return $parameters; 
    6663    } 
    6764 
     
    7067 
    7168  /** 
    72    * Returns true if the parameters matches this route, false otherwise. 
     69   * Returns true if the parameters match this route, false otherwise. 
    7370   * 
    7471   * @param  mixed   $params The parameters 
     
    8279    { 
    8380      // enforce the sf_method requirement 
    84       if (!in_array($params['sf_method'], $this->requirements['sf_method'])) 
     81      if (!in_array(strtolower($params['sf_method']), $this->requirements['sf_method'])) 
    8582      { 
    8683        return false; 
  • branches/1.3/test/unit/routing/sfRequestRouteTest.php

    r20469 r20472  
    1111require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
    1212 
    13 $t = new lime_test(4, new lime_output_color()); 
     13$t = new lime_test(8, new lime_output_color()); 
    1414 
    1515// ->__construct() 
     
    3333$route = new sfRequestRoute('/', array(), array('sf_method' => array('get', 'head'))); 
    3434$t->ok($route->matchesParameters(array('sf_method' => 'get')), '->matchesParameters() matches the "sf_method" parameter'); 
     35 
     36$route = new sfRequestRoute('/', array(), array('sf_method' => array('get'))); 
     37$t->ok($route->matchesParameters(array('sf_method' => 'GET')), '->matchesParameters() checks "sf_method" requirement case-insensitively'); 
     38 
     39$route = new sfRequestRoute('/', array(), array('sf_method' => array('GET'))); 
     40$t->ok($route->matchesParameters(array('sf_method' => 'get')), '->matchesParameters() checks "sf_method" requirement case-insensitively'); 
     41 
     42// ->matchesUrl() 
     43$t->diag('->matchesUrl()'); 
     44 
     45$route = new sfRequestRoute('/', array(), array('sf_method' => 'GET')); 
     46$t->isa_ok($route->matchesUrl('/', array('method' => 'get')), 'array', '->matchesUrl() check "sf_method" requirement case-insensitively'); 
     47 
     48$route = new sfRequestRoute('/', array(), array('sf_method' => 'get')); 
     49$t->isa_ok($route->matchesUrl('/', array('method' => 'GET')), 'array', '->matchesUrl() check "sf_method" requirement case-insensitively');