bundled-libs
Cache
HTTP
Net
Onyx
Smarty
libs
plugins
block.textformat.php
function.counter.php
function.cycle.php
function.fetch.php
function.html_checkboxes.php
function.html_image.php
function.html_options.php
function.html_radios.php
function.html_select_date.php
function.html_select_time.php
function.html_table.php
function.mailto.php
function.math.php
modifier.capitalize.php
modifier.date_format.php
modifier.debug_print_var.php
modifier.escape.php
modifier.regex_replace.php
modifier.replace.php
modifier.spacify.php
modifier.truncate.php
modifiercompiler.cat.php
modifiercompiler.count_characters.php
modifiercompiler.count_paragraphs.php
modifiercompiler.count_sentences.php
modifiercompiler.count_words.php
modifiercompiler.default.php
modifiercompiler.escape.php
modifiercompiler.from_charset.php
modifiercompiler.indent.php
modifiercompiler.lower.php
modifiercompiler.noprint.php
modifiercompiler.string_format.php
modifiercompiler.strip.php
modifiercompiler.strip_tags.php
modifiercompiler.to_charset.php
modifiercompiler.unescape.php
modifiercompiler.upper.php
modifiercompiler.wordwrap.php
outputfilter.trimwhitespace.php
shared.escape_special_chars.php
shared.literal_compiler_param.php
shared.make_timestamp.php
shared.mb_str_replace.php
shared.mb_unicode.php
shared.mb_wordwrap.php
variablefilter.htmlspecialchars.php
sysplugins
Smarty.class.php
SmartyBC.class.php
debug.tpl
COPYING.lib
README
SMARTY_2_BC_NOTES.txt
SMARTY_3.0_BC_NOTES.txt
SMARTY_3.1_NOTES.txt
change_log.txt
Text
XML
docs
tests
.current_version
PEAR.php
create_release.sh
serendipity_generateFTPChecksums.php
deployment
docs
htmlarea
include
lang
plugins
sql
templates
templates_c
tests
uploads
.gitignore
README.markdown
checksums.inc.php
comment.php
exit.php
index.php
rss.php
serendipity.css.php
serendipity_admin.php
serendipity_admin_image_selector.php
serendipity_config.inc.php
serendipity_define.js.php
serendipity_editor.js
serendipity_xmlrpc.php
wfwcomment.php
90 lines
3.2 KiB
PHP
90 lines
3.2 KiB
PHP
<?php
|
|
/**
|
|
* Smarty plugin
|
|
*
|
|
* @package Smarty
|
|
* @subpackage PluginsModifierCompiler
|
|
*/
|
|
|
|
/**
|
|
* @ignore
|
|
*/
|
|
require_once( SMARTY_PLUGINS_DIR .'shared.literal_compiler_param.php' );
|
|
|
|
/**
|
|
* Smarty escape modifier plugin
|
|
*
|
|
* Type: modifier<br>
|
|
* Name: escape<br>
|
|
* Purpose: escape string for output
|
|
*
|
|
* @link http://www.smarty.net/docsv2/en/language.modifier.escape count_characters (Smarty online manual)
|
|
* @author Rodney Rehm
|
|
* @param array $params parameters
|
|
* @return string with compiled code
|
|
*/
|
|
function smarty_modifiercompiler_escape($params, $compiler)
|
|
{
|
|
try {
|
|
$esc_type = smarty_literal_compiler_param($params, 1, 'html');
|
|
$char_set = smarty_literal_compiler_param($params, 2, Smarty::$_CHARSET);
|
|
$double_encode = smarty_literal_compiler_param($params, 3, true);
|
|
|
|
if (!$char_set) {
|
|
$char_set = Smarty::$_CHARSET;
|
|
}
|
|
|
|
switch ($esc_type) {
|
|
case 'html':
|
|
return 'htmlspecialchars('
|
|
. $params[0] .', ENT_QUOTES, '
|
|
. var_export($char_set, true) . ', '
|
|
. var_export($double_encode, true) . ')';
|
|
|
|
case 'htmlall':
|
|
if (Smarty::$_MBSTRING) {
|
|
return 'mb_convert_encoding(htmlspecialchars('
|
|
. $params[0] .', ENT_QUOTES, '
|
|
. var_export($char_set, true) . ', '
|
|
. var_export($double_encode, true)
|
|
. '), "HTML-ENTITIES", '
|
|
. var_export($char_set, true) . ')';
|
|
}
|
|
|
|
// no MBString fallback
|
|
return 'htmlentities('
|
|
. $params[0] .', ENT_QUOTES, '
|
|
. var_export($char_set, true) . ', '
|
|
. var_export($double_encode, true) . ')';
|
|
|
|
case 'url':
|
|
return 'rawurlencode(' . $params[0] . ')';
|
|
|
|
case 'urlpathinfo':
|
|
return 'str_replace("%2F", "/", rawurlencode(' . $params[0] . '))';
|
|
|
|
case 'quotes':
|
|
// escape unescaped single quotes
|
|
return 'preg_replace("%(?<!\\\\\\\\)\'%", "\\\'",' . $params[0] . ')';
|
|
|
|
case 'javascript':
|
|
// escape quotes and backslashes, newlines, etc.
|
|
return 'strtr(' . $params[0] . ', array("\\\\" => "\\\\\\\\", "\'" => "\\\\\'", "\"" => "\\\\\"", "\\r" => "\\\\r", "\\n" => "\\\n", "</" => "<\/" ))';
|
|
|
|
}
|
|
} catch(SmartyException $e) {
|
|
// pass through to regular plugin fallback
|
|
}
|
|
|
|
// could not optimize |escape call, so fallback to regular plugin
|
|
if ($compiler->tag_nocache | $compiler->nocache) {
|
|
$compiler->template->required_plugins['nocache']['escape']['modifier']['file'] = SMARTY_PLUGINS_DIR .'modifier.escape.php';
|
|
$compiler->template->required_plugins['nocache']['escape']['modifier']['function'] = 'smarty_modifier_escape';
|
|
} else {
|
|
$compiler->template->required_plugins['compiled']['escape']['modifier']['file'] = SMARTY_PLUGINS_DIR .'modifier.escape.php';
|
|
$compiler->template->required_plugins['compiled']['escape']['modifier']['function'] = 'smarty_modifier_escape';
|
|
}
|
|
return 'smarty_modifier_escape(' . join( ', ', $params ) . ')';
|
|
}
|
|
|
|
?>
|