Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#106 html tags white list #139

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions gump.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ public static function get_instance(){

public static $basic_tags = '<br><p><a><strong><b><i><em><img><blockquote><code><dd><dl><hr><h1><h2><h3><h4><h5><h6><label><ul><li><span><sub><sup>';

// By default the instance_tags are the basic tags, but they can be changed on a per instance
// of GUMP basis (see the constructor)
public $instance_tags;

public static $en_noise_words = "about,after,all,also,an,and,another,any,are,as,at,be,because,been,before,
being,between,both,but,by,came,can,come,could,did,do,each,for,from,get,
got,has,had,he,have,her,here,him,himself,his,how,if,in,into,is,it,its,it's,like,
Expand All @@ -66,6 +70,15 @@ public static function get_instance(){
// field characters below will be replaced with a space.
protected $fieldCharsToRemove = array('_', '-');

public function __construct($opts = array()) {
$this->instance_tags = static::$basic_tags;

// permit overrides
foreach($opts as $key => $value) {
$this->$key = $value;
}
}

// ** ------------------------- Validation Helpers ---------------------------- ** //

/**
Expand Down Expand Up @@ -325,7 +338,9 @@ public function sanitize(array $input, array $fields = array(), $utf8_encode = t
}
}

$value = filter_var($value, FILTER_SANITIZE_STRING);
// old code - filter_var($value, FILTER_SANITIZE_STRING);
// See #106 https://github.com/Wixel/GUMP/issues/106
$value = $this->filter_basic_tags($value);
}

$return[$field] = $value;
Expand Down Expand Up @@ -927,7 +942,7 @@ protected function filter_sanitize_numbers($value, $params = null)
*/
protected function filter_basic_tags($value, $params = null)
{
return strip_tags($value, self::$basic_tags);
return strip_tags($value, $this->instance_tags);
}

/**
Expand Down