Development

Changeset 20298

You must first sign up to be able to contribute.

Changeset 20298

Show
Ignore:
Timestamp:
07/19/09 12:43:11 (4 years ago)
Author:
fabien
Message:

[1.2, 1.3] fixed sfForm::setDefaults() ignores individual CSRF protection (closes #6864)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.2/lib/form/sfForm.class.php

    r17858 r20298  
    752752    $this->defaults = is_null($defaults) ? array() : $defaults; 
    753753 
    754     if (self::$CSRFProtection
     754    if ($this->isCSRFProtected()
    755755    { 
    756756      $this->setDefault(self::$CSRFFieldName, $this->getCSRFToken(self::$CSRFSecret)); 
  • branches/1.2/test/unit/form/sfFormTest.php

    r19780 r20298  
    1111require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
    1212 
    13 $t = new lime_test(144, new lime_output_color()); 
     13$t = new lime_test(145, new lime_output_color()); 
    1414 
    1515class FormTest extends sfForm 
     
    123123$f->setDefaults(array('first_name' => 'Fabien')); 
    124124$t->is($f->getDefault('_csrf_token'), $f->getCSRFToken('*mygreatsecret*'), '->getDefaults() keeps the CSRF token default value'); 
     125 
     126$f = new FormTest(array(), array(), false); 
     127$f->setDefaults(array('first_name' => 'Fabien')); 
     128$t->is(array_key_exists('_csrf_token', $f->getDefaults()), false, '->setDefaults() does not set the CSRF token if CSRF is disabled'); 
    125129sfForm::disableCSRFProtection(); 
    126130 
  • branches/1.3/lib/form/sfForm.class.php

    r19162 r20298  
    762762    $this->defaults = is_null($defaults) ? array() : $defaults; 
    763763 
    764     if (self::$CSRFProtection
     764    if ($this->isCSRFProtected()
    765765    { 
    766766      $this->setDefault(self::$CSRFFieldName, $this->getCSRFToken(self::$CSRFSecret)); 
  • branches/1.3/test/unit/form/sfFormTest.php

    r19780 r20298  
    1111require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
    1212 
    13 $t = new lime_test(146); 
     13$t = new lime_test(147); 
    1414 
    1515class FormTest extends sfForm 
     
    123123$f->setDefaults(array('first_name' => 'Fabien')); 
    124124$t->is($f->getDefault('_csrf_token'), $f->getCSRFToken('*mygreatsecret*'), '->getDefaults() keeps the CSRF token default value'); 
     125 
     126$f = new FormTest(array(), array(), false); 
     127$f->setDefaults(array('first_name' => 'Fabien')); 
     128$t->is(array_key_exists('_csrf_token', $f->getDefaults()), false, '->setDefaults() does not set the CSRF token if CSRF is disabled'); 
    125129sfForm::disableCSRFProtection(); 
    126130