Page 1 of 1
chtmlpurifier to purify tinymce output
#1
Posted 26 September 2011 - 03:39 PM
I would like to implement chtmlpurifier on all pages that has tinymce with default config on input. Can any one tell me which is the best way to attach this feature (as behavior,as an extension to tinymce,as an event ...)?
#2
Posted 27 September 2011 - 06:11 AM
AFAIK, TinyMCE already does this - so no need to do it again.
"Less noise - more signal"
#4
Posted 27 September 2011 - 09:31 AM
jacmoe It does nothing, turn of javascript, and you will get XSS
read documentation
http://www.yiiframework.com/doc/api/1.1/CHtmlPurifier
you can use it as filter
read documentation
http://www.yiiframework.com/doc/api/1.1/CHtmlPurifier
you can use it as filter
Certification:

Test Yii:
Yii Framework Demos
Wiki:
Common Yii Questions
Tutorials:
Demo Blog Search with Zend_Lucene
Fundamentals:
Yii "registry" | Understanding the layout->view randering flow
Etc:
Shrink Yii | Caching config/main.php | CPhpAuthManager - how it works, and when to use it
Extensions:
Theme Picker | Language Picker (i18n)

Test Yii:
Yii Framework Demos
Wiki:
Common Yii Questions
Tutorials:
Demo Blog Search with Zend_Lucene
Fundamentals:
Yii "registry" | Understanding the layout->view randering flow
Etc:
Shrink Yii | Caching config/main.php | CPhpAuthManager - how it works, and when to use it
Extensions:
Theme Picker | Language Picker (i18n)
#5
Posted 28 September 2011 - 12:43 PM
dckurushin, on 27 September 2011 - 09:31 AM, said:
jacmoe It does nothing, turn of javascript, and you will get XSS
read documentation
http://www.yiiframework.com/doc/api/1.1/CHtmlPurifier
you can use it as filter
read documentation
http://www.yiiframework.com/doc/api/1.1/CHtmlPurifier
you can use it as filter
Thank you.
#6
Posted 28 September 2011 - 01:09 PM
Heh - I am actually doing this myself by means of a simple behavior:
Then in my model(s):
It is so transparent that I forgot that I used it!
<?php
class CSafeContentBehavior extends CActiveRecordBehavior
{
public $attributes =array();
protected $purifier;
function __construct(){
$this->purifier = new CHtmlPurifier;
}
public function beforeSave($event)
{
foreach($this->attributes as $attribute){
$this->getOwner()->{$attribute} = $this->purifier->purify($this->getOwner()->{$attribute});
}
}
}
Then in my model(s):
public function behaviors()
{
return array(
'CSafeContentBehavior'=>array(
'class' => 'application.models.behaviors.CSafeContentBehavior',
'attributes' => array('content', 'intro', 'title'),
),
It is so transparent that I forgot that I used it!
"Less noise - more signal"
#7
Posted 03 October 2011 - 12:42 PM
Thanks a bunch Jacmoe, This is exactly what i am looking for.
jacmoe, on 28 September 2011 - 01:09 PM, said:
Heh - I am actually doing this myself by means of a simple behavior:
Then in my model(s):
It is so transparent that I forgot that I used it!
<?php
class CSafeContentBehavior extends CActiveRecordBehavior
{
public $attributes =array();
protected $purifier;
function __construct(){
$this->purifier = new CHtmlPurifier;
}
public function beforeSave($event)
{
foreach($this->attributes as $attribute){
$this->getOwner()->{$attribute} = $this->purifier->purify($this->getOwner()->{$attribute});
}
}
}
Then in my model(s):
public function behaviors()
{
return array(
'CSafeContentBehavior'=>array(
'class' => 'application.models.behaviors.CSafeContentBehavior',
'attributes' => array('content', 'intro', 'title'),
),
It is so transparent that I forgot that I used it!
#8
Posted 03 October 2011 - 05:42 PM
dont reinvent the wheel when you dont need to, this is what framework is all about...
you have a filter, a good one, you dont need to create for this behavior, you can, but it is waste of time
you have a filter, a good one, you dont need to create for this behavior, you can, but it is waste of time
Certification:

Test Yii:
Yii Framework Demos
Wiki:
Common Yii Questions
Tutorials:
Demo Blog Search with Zend_Lucene
Fundamentals:
Yii "registry" | Understanding the layout->view randering flow
Etc:
Shrink Yii | Caching config/main.php | CPhpAuthManager - how it works, and when to use it
Extensions:
Theme Picker | Language Picker (i18n)

Test Yii:
Yii Framework Demos
Wiki:
Common Yii Questions
Tutorials:
Demo Blog Search with Zend_Lucene
Fundamentals:
Yii "registry" | Understanding the layout->view randering flow
Etc:
Shrink Yii | Caching config/main.php | CPhpAuthManager - how it works, and when to use it
Extensions:
Theme Picker | Language Picker (i18n)
#10
Posted 13 May 2012 - 11:54 PM
I think dckurushin means
class PostController extends CController
{
......
public function filters()
{
return array(
'postOnly + edit, create',
array(
'application.filters.PerformanceFilter - edit, create',
'unit'=>'second',
),
);
}
}
Share this topic:
Page 1 of 1

Help













