Skip to content
Browse files

reworking to include @dhorrigan's suggestions for filter_var and the …

…htmlentities encoding
  • Loading branch information...
1 parent ded0dec commit 7d29d9dd75fdedc536643d9ee092321333ab2fd5 Chris Cornutt committed Aug 10, 2012
Showing with 7 additions and 3 deletions.
  1. +7 −3 Shield/Filter.php
View
10 Shield/Filter.php
@@ -37,7 +37,7 @@ public function add($name, $type = null)
foreach ($name as $n => $type) {
if ($type == null) { continue; }
-
+
if (isset($this->filters[$n])) {
$this->filters[$n][] = $type;
} else {
@@ -77,7 +77,11 @@ public function filter($name, $value)
$filters = $this->get($name);
if (count($filters) == 0) {
- $filters = array('htmlentities');
+ if ($value == null && is_string($value)) {
+ $charset = Config::get('view.charset');
+ $encoding = ($charset !== null) ? $charset : 'UTF-8';
+ $value = htmlentities($value, ENT_QUOTES, $encoding, false);
+ }
}
foreach ($filters as $filter) {
if ($filter instanceof \Closure) {
@@ -115,7 +119,7 @@ private function filterEmail($value)
*/
private function filterStriptags($value)
{
- return strip_tags($value);
+ return filter_var($value, FILTER_SANITIZE_STRING);
}
/**

0 comments on commit 7d29d9d

Please sign in to comment.
Something went wrong with that request. Please try again.