$replacements = array("&", "%", "<", ">", '"', "'", "(", ")", "+", "-");
$string = preg_replace($patterns, $replacements, $string);
+ $string = preg_replace('/\\\n/', "\n", $string);
if ($strip_all) {
$string = Sanitize::stripAll($string);
}
}
+ function _unsecape_recursive($value, $funcname, $noescape_list = null ,$parent_key = null) {
+ if (is_array($value)) {
+ foreach ($value as $key => $val) {
+ $parent_key_arr = ( isset($parent_key) ) ? $parent_key . '.' . $key : $key ;
+
+
+ $value[$key] = self::_unsecape_recursive($val, $funcname, $noescape_list, $parent_key_arr);
+ }
+ return $value;
+ } else {
+ if( is_array($noescape_list) ){
+ foreach( $noescape_list as $noescape_value ){
+ $noescape_value = str_replace( ".", '\.' , $noescape_value );
+
+ if( preg_match( "/^(.+\.|)$noescape_value(\..+|)$/", $parent_key ) ){
+ return $value;
+ }
+ }
+ }
+ $value = call_user_func(array('HtmlEscapeComponent', $funcname), $value);
+
+ return $value;
+ }
+ }
+
+ /**
+ * Execute nl2br() to escaped Array Data
+ *
+ * @param string or array $value
+ * @param array $noescape_list
+ * @param string $parent_key
+ * @return string or array
+ */
+ function nl2br_escaped( $value, $noescape_list = null ,$parent_key = null ) {
+ return $this->_unsecape_recursive($value, "_nl2br_escaped", $noescape_list, $parent_key);
+ }
+
+ /**
+ * Execute unescape Array Data
+ *
+ * @param string or array $value
+ * @param array $noescape_list
+ * @param string $parent_key
+ * @return string or array
+ */
+ function nl_unescape($value, $noescape_list = null ,$parent_key = null ) {
+ return $this->_unsecape_recursive($value, "_nl_unescape", $noescape_list, $parent_key);
+ }
+
/**
* Execute nl2br() and h() to String Data
return nl2br( h( $value, $charset ) );
}
+ /**
+ * Execute nl2br() to escaped String Data
+ * @param string $value
+ * @return string
+ */
+ function _nl2br_escaped(&$value) {
+ $value = $this->nl_unescape($value);
+ return nl2br($value);
+ }
+
+ /**
+ * Execute unescape String Data
+ * @param string $value
+ * @return string
+ */
+ function _nl_unescape($value) {
+ return preg_replace('/\\\n/', "\n", $value);
+ }
+
}
?>