-
Notifications
You must be signed in to change notification settings - Fork 454
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
167 changed files
with
32,154 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
$config['settings'] = array( | ||
'default' => array( | ||
'HTML.Doctype' => 'XHTML 1.0 Strict', | ||
'HTML.Allowed' => 'div,b,strong,i,em,a[href|title],ul,ol,li,p[style],br,span[style],img[width|height|alt|src]', | ||
//'CSS.AllowedProperties' => 'font,font-size,font-weight,font-style,font-family,text-decoration,padding-left,color,background-color,text-align,float,margin', | ||
'AutoFormat.AutoParagraph' => false, // This will cause errors if you globally apply this to input being saved to the database so we set it to false. | ||
'AutoFormat.RemoveEmpty' => true, | ||
), | ||
'comment' => array( | ||
'HTML.Doctype' => 'XHTML 1.0 Strict', | ||
'HTML.Allowed' => 'p,a[href|title],abbr[title],acronym[title],b,strong,blockquote[cite],code,em,i,strike', | ||
'CSS.AllowedProperties' => 'font,font-size,font-weight,font-style,font-family,text-decoration,padding-left,color,background-color,text-align,float,margin', | ||
'AutoFormat.AutoParagraph' => true, | ||
'AutoFormat.Linkify' => true, | ||
'AutoFormat.RemoveEmpty' => true, | ||
), | ||
'youtube' => array( | ||
'HTML.SafeIframe' => 'true', | ||
'URI.SafeIframeRegexp' => "%^(http://|https://|//)(www.youtube.com/embed/|player.vimeo.com/video/)%", | ||
) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -151,5 +151,121 @@ function html_attrs($attrs) | |
} | ||
} | ||
|
||
// https://github.com/refringe/CodeIgniter-HTMLPurifier/blob/master/htmlpurifier_helper.php | ||
/* | ||
* Codeigniter HTMLPurifier Helper | ||
* | ||
* Purify input using the HTMLPurifier standalone class. | ||
* Easily use multiple purifier configurations. | ||
* | ||
* @author Tyler Brownell <[email protected]> | ||
* @copyright Public Domain | ||
* | ||
* @access public | ||
* @param string or array $dirty_html A string (or array of strings) to be cleaned. | ||
* @param string $config The name of the configuration (switch case) to use. | ||
* @param boolean $replace Determines whether to replace the main config or append to it. | ||
* @param boolean $remove_allowed_funcs Determines whether search for allowed functions to remove. | ||
* @return string or array The cleaned string (or array of strings). | ||
*/ | ||
if (!function_exists('html_purify')) | ||
{ | ||
function html_purify($dirty_html, $config = [], $replace = false, $remove_allowed_funcs = false) | ||
{ | ||
if (!is_string($dirty_html) OR is_numeric($dirty_html)) | ||
{ | ||
return $dirty_html; | ||
} | ||
|
||
// Modified to include the library if it doesn't exist | ||
require_once(FUEL_PATH.'libraries/HTMLPurifier/HTMLPurifier.standalone.php'); | ||
|
||
$CI = &get_instance(); | ||
$CI->load->config('purifier', TRUE); | ||
|
||
$settings = $CI->config->item('settings', 'purifier'); | ||
|
||
if (is_array($dirty_html)) | ||
{ | ||
foreach ($dirty_html as $key => $val) | ||
{ | ||
$clean_html[$key] = html_purify($val, $config, $replace); | ||
} | ||
|
||
} else { | ||
|
||
if (is_string($config) AND isset($settings[$config])) | ||
{ | ||
$config = $settings[$config]; | ||
} | ||
else | ||
{ | ||
$config = ($replace) ? $config : array_merge($settings['default'], $config); | ||
} | ||
|
||
// This is no bueno when sanitizing data so we make sure it's not set unless explicitly passed. | ||
if (!isset($config['AutoFormat.AutoParagraph'])) | ||
{ | ||
$config['AutoFormat.AutoParagraph'] = false; | ||
} | ||
|
||
$encodeAmpersands = true; | ||
|
||
if (isset($config['HTML.EncodeAmpersand']) && $config['HTML.EncodeAmpersand'] === false) | ||
{ | ||
$encodeAmpersands = false; | ||
unset($config['HTML.EncodeAmpersand']); | ||
} | ||
|
||
if ($encodeAmpersands) | ||
{ | ||
$dirty_html = preg_replace('/&(?![a-z#]+;)/i', '__TEMP_AMP__', $dirty_html); | ||
} | ||
|
||
if (empty($config)) | ||
{ | ||
show_error('No HTML purifier configuration found'); | ||
} | ||
|
||
$purifier_config = \HTMLPurifier_Config::createDefault(); | ||
$purifier_config->set('Core.Encoding', $CI->config->item('charset')); | ||
|
||
if (!$remove_allowed_funcs) | ||
{ | ||
$allowed_funcs = $CI->fuel->config('parser_allowed_functions'); | ||
$parse_delimiters = $CI->fuel->config('parser_delimiters'); | ||
$tag_delimiters = $parse_delimiters['tag_variable']; | ||
$keep_replace = array('__TEMP_LEFT_CURLY_BRACE__', '__TEMP_RIGHT_CURLY_BRACE__'); | ||
|
||
// Escape functions that are allowed with delimiters | ||
$funcs = implode('|', $allowed_funcs); | ||
$regex = '#'.preg_quote($tag_delimiters[0]).'.*(('.$funcs.')\(.*\).*)'.preg_quote($tag_delimiters[1]).'#U'; | ||
$dirty_html = preg_replace($regex, $keep_replace[0].'$1'.$keep_replace[1], $dirty_html); | ||
} | ||
|
||
foreach ($config as $key => $val) | ||
{ | ||
$purifier_config->set($key, $val); | ||
} | ||
|
||
$purifier_config = \HTMLPurifier_Config::createDefault(); | ||
$purifier = new \HTMLPurifier($purifier_config); | ||
$clean_html = $purifier->purify($dirty_html); | ||
|
||
if ($encodeAmpersands) | ||
{ | ||
$clean_html = str_replace('__TEMP_AMP__', '&', $clean_html); | ||
} | ||
|
||
if (!$remove_allowed_funcs) | ||
{ | ||
$clean_html = str_replace($keep_replace, $tag_delimiters, $clean_html); | ||
} | ||
} | ||
|
||
return $clean_html; | ||
} | ||
} | ||
|
||
/* End of file MY_html_helper.php */ | ||
/* Location: ./modules/fuel/helpers/MY_html_helper.php */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.