diff --git a/e107_handlers/e_parse_class.php b/e107_handlers/e_parse_class.php index 867afdbb0..f93a1a69b 100644 --- a/e107_handlers/e_parse_class.php +++ b/e107_handlers/e_parse_class.php @@ -4800,8 +4800,17 @@ class e_parse /** * Filters/Validates using the PHP5 filter_var() method. + * * @param string|array $text - * @param string $type string str|int|email|url|w|wds|file + * @param string $type str|int|email|url|w|wds|file + * + * If the type is "str" (default), HTML tags are stripped, and quotation marks are escaped for + * HTML with the intention of making the string safe to use in both concatenated SQL queries and + * HTML code. + * + * Despite the intention, strings returned by this function should still be specified as values + * in SQL prepared statements or surrounded by {@see mysqli_real_escape_string()} if the string + * is to be written to the database. * @return string|boolean| array */ public function filter($text, $type = 'str', $validate = false) @@ -4859,7 +4868,10 @@ class e_parse { $filterTypes = array( 'int' => FILTER_SANITIZE_NUMBER_INT, - 'str' => function($input) { return strip_tags($input); }, + 'str' => function($input) + { + return htmlspecialchars(strip_tags($input), ENT_QUOTES); + }, 'email' => FILTER_SANITIZE_EMAIL, 'url' => FILTER_SANITIZE_URL, 'enc' => FILTER_SANITIZE_ENCODED diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php index 399189d31..2d7c9491e 100644 --- a/e107_handlers/form_handler.php +++ b/e107_handlers/form_handler.php @@ -151,35 +151,46 @@ class e_form if(!empty($options['class'])) { - $class = "class='".$options['class']."'"; + $class = $options['class']; } else // default { - $class= "class='form-horizontal'"; + $class = "form-horizontal"; } if(isset($options['autocomplete'])) // leave as isset() { - $autoComplete = " autocomplete='".($options['autocomplete'] ? 'on' : 'off')."'"; + $autoComplete = $options['autocomplete'] ? 'on' : 'off'; } if($method === 'get' && strpos($target,'=')) { - list($url,$qry) = explode('?',$target); - $text = "\n
\n"; - - parse_str($qry,$m); - foreach($m as $k=>$v) + list($url, $qry) = explode('?', $target); + $text = "\nattributes([ + 'class' => $class, + 'action' => $url, + 'id' => $this->name2id($name), + 'method' => $method, + 'autocomplete' => $autoComplete, + ]) . ">\n"; + + parse_str($qry, $m); + foreach ($m as $k => $v) { - $text .= $this->hidden($k, $v); + $text .= $this->hidden($k, $v); } - - } - else + + } + else { - $target = str_replace('&', '&', $target); - $text = "\n\n"; + $text = "\nattributes([ + 'class' => $class, + 'action' => $target, + 'id' => $this->name2id($name), + 'method' => $method, + 'autocomplete' => $autoComplete, + ]) . ">\n"; } return $text; } @@ -630,37 +641,27 @@ class e_form */ public function carousel($name= 'e-carousel', $array=array(), $options = null) { - $interval = null; - $wrap = null; - $pause = null; $indicators = ''; $controls = ''; $act = varset($options['default'], 0); - - if(isset($options['wrap'])) - { - $wrap = 'data-wrap="'.$options['wrap'].'"'; - } - - if(isset($options['interval'])) - { - $interval = 'data-interval="'.$options['interval'].'"'; - } - - if(isset($options['pause'])) - { - $pause = 'data-pause="'.$options['pause'].'"'; - } $navigation = isset($options['navigation']) ? $options['navigation'] : true; $indicate = isset($options['indicators']) ? $options['indicators'] : true; - $start =' + $start = ' -