mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge branch '4' into 5.1
This commit is contained in:
commit
e68af4de40
@ -138,8 +138,7 @@ class HTMLEditorField extends TextareaField
|
||||
// Sanitise if requested
|
||||
$htmlValue = HTMLValue::create($this->Value());
|
||||
if (HTMLEditorField::config()->sanitise_server_side) {
|
||||
$config = $this->getEditorConfig();
|
||||
$santiser = HTMLEditorSanitiser::create($config);
|
||||
$santiser = HTMLEditorSanitiser::create(HTMLEditorConfig::get_active());
|
||||
$santiser->sanitise($htmlValue);
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,6 @@ use SilverStripe\Control\Director;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Dev\CSSContentParser;
|
||||
use SilverStripe\Dev\FunctionalTest;
|
||||
use SilverStripe\Forms\HTMLEditor\HTMLEditorConfig;
|
||||
use SilverStripe\Forms\HTMLEditor\HTMLEditorField;
|
||||
use SilverStripe\Forms\HTMLEditor\TinyMCEConfig;
|
||||
use SilverStripe\Forms\HTMLReadonlyField;
|
||||
@ -232,43 +231,6 @@ EOS
|
||||
);
|
||||
}
|
||||
|
||||
public function testFieldConfigSanitization()
|
||||
{
|
||||
$obj = TestObject::create();
|
||||
$editor = HTMLEditorField::create('Content');
|
||||
$defaultValidElements = [
|
||||
'@[id|class|style|title|data*]',
|
||||
'a[id|rel|dir|tabindex|accesskey|type|name|href|target|title|class]',
|
||||
'-strong/-b[class]',
|
||||
'-em/-i[class]',
|
||||
'-ol[class]',
|
||||
'#p[id|dir|class|align|style]',
|
||||
'-li[class]',
|
||||
'br',
|
||||
'-span[class|align|style]',
|
||||
'-ul[class]',
|
||||
'-h3[id|dir|class|align|style]',
|
||||
'-h2[id|dir|class|align|style]',
|
||||
'hr[class]',
|
||||
];
|
||||
$restrictedConfig = HTMLEditorConfig::get('restricted');
|
||||
$restrictedConfig->setOption('valid_elements', implode(',', $defaultValidElements));
|
||||
$editor->setEditorConfig($restrictedConfig);
|
||||
|
||||
$expectedHtmlString = '<p>standard text</p>Header';
|
||||
$htmlValue = '<p>standard text</p><table><tbody><tr><th></th></tr><tr><td>Header</td></tr></tbody><tbody></tbody></table>';
|
||||
$editor->setValue($htmlValue);
|
||||
$editor->saveInto($obj);
|
||||
$this->assertEquals($expectedHtmlString, $obj->Content, 'Table is not removed');
|
||||
|
||||
$defaultConfig = HTMLEditorConfig::get('default');
|
||||
$editor->setEditorConfig($defaultConfig);
|
||||
|
||||
$editor->setValue($htmlValue);
|
||||
$editor->saveInto($obj);
|
||||
$this->assertEquals($htmlValue, $obj->Content, 'Table is removed');
|
||||
}
|
||||
|
||||
public function testGetAttributes()
|
||||
{
|
||||
// If silverstripe/admin isn't installed, we can't get TinyMCEConfig attributes
|
||||
|
Loading…
Reference in New Issue
Block a user