Changeset 1663

Show
Ignore:
Timestamp:
03/02/10 13:50:21 (5 months ago)
Author:
martin
Message:

Made widgets use new purification validator; further escaping fixes, fixed tests

Location:
trunk
Files:
10 modified

Legend:

Unmodified
Added
Removed
  • trunk/plugins/ullCorePlugin/lib/form/widget/ullMetaWidgetString.class.php

    r984 r1663  
    1010  protected function configureReadMode() 
    1111  { 
    12      $this->addWidget(new ullWidget($this->columnConfig->getWidgetOptions(), $this->columnConfig->getWidgetAttributes())); 
    13      $this->addValidator(new sfValidatorPass()); 
     12    $this->columnConfig->removeWidgetOption('disablePurification'); 
     13     
     14    $this->addWidget(new ullWidget($this->columnConfig->getWidgetOptions(), $this->columnConfig->getWidgetAttributes())); 
     15    $this->addValidator(new sfValidatorPass()); 
    1416  } 
    1517   
     
    2123    } 
    2224     
     25    if ($this->columnConfig->getWidgetOption('disablePurification')) 
     26    { 
     27      $this->addValidator(new sfValidatorString($this->columnConfig->getValidatorOptions()));  
     28    } 
     29    else 
     30    { 
     31      $this->addValidator(new ullValidatorPurifiedString($this->columnConfig->getValidatorOptions()));  
     32    } 
     33     
     34    $this->columnConfig->removeWidgetOption('disablePurification'); 
     35     
    2336    $this->addWidget(new sfWidgetFormInput($this->columnConfig->getWidgetOptions(), $this->columnConfig->getWidgetAttributes())); 
    24     $this->addValidator(new sfValidatorString($this->columnConfig->getValidatorOptions()));  
    2537  } 
    26    
    2738} 
  • trunk/plugins/ullCorePlugin/lib/form/widget/ullWidgetFormInput.php

    r1041 r1663  
    1212  { 
    1313    $suffix = $this->getOption('suffix'); 
    14     return parent::render($name, $value, $attributes, $errors) . ' ' . $suffix; 
     14 
     15    $result = parent::render($name, $value, $attributes, $errors); 
     16    return $result . (!empty($suffix) ? ' ' . $suffix : ''); 
    1517  } 
    1618} 
  • trunk/plugins/ullCorePlugin/lib/form/widget/ullWidgetTextarea.php

    r1203 r1663  
    1313    if ($value) 
    1414    { 
    15       $value = nl2br($value); 
     15      //escape the string (to prevent injection of js, etc.) 
     16      //and convert newlines to br tags 
     17      $value = nl2br(esc_entities($value)); 
    1618    } 
    1719    else 
  • trunk/plugins/ullFlowPlugin/data/fixtures/ullFlowFixtures.yml

    r1175 r1663  
    161161    is_mandatory:   true 
    162162    is_subject:     true 
     163    options:        disablePurification=true 
    163164    namespace:      test 
    164165     
     
    248249    is_mandatory:   true 
    249250    is_subject:     true 
     251    options:        disablePurification=true 
    250252    namespace:      test 
    251253     
  • trunk/plugins/ullWikiPlugin/lib/generator/columnConfigCollection/UllWikiColumnConfigCollection.class.php

    r1470 r1663  
    3434    if ($this->isCreateOrEditAction()) 
    3535    { 
     36      $this['subject']->setWidgetOption('disablePurification', true); 
     37       
    3638      $this->disable(array('id', 'updator_user_id', 'updated_at')); 
    3739    }     
  • trunk/test/unit/ullFlowPlugin/ullFlowGeneratorTest.php

    r1437 r1663  
    1414    $columnConfig->setMetaWidgetClassName('ullMetaWidgetString'); 
    1515    $columnConfig->setIsInList(false); 
     16    $columnConfig->setWidgetOption('disablePurification', true); 
    1617    $this->columnsConfigMock['my_subject'] = $columnConfig; 
    1718     
  • trunk/test/unit/ullTableTool/ullMetaWidgetLinkTest.php

    r857 r1663  
    3434  $widget->addToFormAs('my_field'); 
    3535  $t->isa_ok($form->getWidgetSchema()->offsetGet('my_field'), 'sfWidgetFormInput', 'returns the correct widget for write access'); 
    36   $t->isa_ok($form->getValidatorSchema()->offsetGet('my_field'), 'sfValidatorString', 'returns the correct validator for write access'); 
     36  $t->isa_ok($form->getValidatorSchema()->offsetGet('my_field'), 'ullValidatorPurifiedString', 'returns the correct validator for write access'); 
    3737   
  • trunk/test/unit/ullTableTool/ullMetaWidgetStringTest.php

    r857 r1663  
    3434  $widget->addToFormAs('my_field'); 
    3535  $t->isa_ok($form->getWidgetSchema()->offsetGet('my_field'), 'sfWidgetFormInput', 'returns the correct widget for write access'); 
    36   $t->isa_ok($form->getValidatorSchema()->offsetGet('my_field'), 'sfValidatorString', 'returns the correct validator for write access'); 
     36  $t->isa_ok($form->getValidatorSchema()->offsetGet('my_field'), 'ullValidatorPurifiedString', 'returns the correct validator for write access'); 
    3737   
  • trunk/test/unit/ullTableTool/ullWidgetFloatWriteTest.php

    r1042 r1663  
    1010 
    1111$t->diag('->render() with default culture'); 
    12 $reference = '<input type="text" name="foo" value="-423,342.64" id="foo" /> '; 
     12$reference = '<input type="text" name="foo" value="-423,342.64" id="foo" />'; 
    1313$t->is($w->render('foo', '-423342.64'), $reference, '->render() renders correctly.'); 
    1414 
     
    1717 
    1818$t->diag('->render() with \'de\' culture'); 
    19 $reference = '<input type="text" name="foo" value="-423.342,64" id="foo" /> '; 
     19$reference = '<input type="text" name="foo" value="-423.342,64" id="foo" />'; 
    2020$t->is($w->render('foo', '-423342.64'), $reference, '->render() renders correctly.'); 
  • trunk/test/unit/ullTableTool/ullWidgetTextareaTest.php

    r1080 r1663  
    33require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
    44 
    5 sfLoader::loadHelpers(array('Text', 'Tag')); 
     5sfLoader::loadHelpers(array('Text', 'Tag', 'Escaping')); 
    66 
    7 $t = new lime_test(4, new lime_output_color(), $configuration); 
     7$t = new lime_test(5, new lime_output_color(), $configuration); 
    88 
    99$w = new ullWidgetTextarea(); 
     
    1515  $t->is($w->render('foo', "vertebratehttp://www.foobar.com fish"), 
    1616        'vertebrate<a href="http://www.foobar.com">http://www.foobar.com</a> fish', '->render() renders the widget as HTML'); 
     17  $t->is($w->render('foo', "<script>bad<"), "&lt;script&gt;bad&lt;", '->render() renders the widget as HTML');