diff options
author | Matthieu Aubry <mattab@users.noreply.github.com> | 2016-12-02 07:32:03 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-02 07:32:03 +0300 |
commit | 95dff7b6812f54c1afc67d6781a5d01d47c3ca60 (patch) | |
tree | 3c49147c490360c0d436dba0e1c9690d9978bd0b /core/UrlHelper.php | |
parent | 28409d4c92f46ce3b250501c769bb08ebb26884c (diff) | |
parent | 59ba07cba11cd51a49ba5a4946abee0d34c4c7a9 (diff) |
Merge pull request #10945 from piwik/3.x-dev3.0.0-b4
Piwik 3.0.0-b4 release
Diffstat (limited to 'core/UrlHelper.php')
-rw-r--r-- | core/UrlHelper.php | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/core/UrlHelper.php b/core/UrlHelper.php index 66a0e64e25..f9d2bac83e 100644 --- a/core/UrlHelper.php +++ b/core/UrlHelper.php @@ -17,6 +17,32 @@ use Piwik\Intl\Data\Provider\RegionDataProvider; */ class UrlHelper { + + /** + * Checks if a string matches/is equal to one of the patterns/strings. + * + * @static + * @param $test String to test. + * @param $patterns Array of strings or regexs. + * + * @return true if $test matches or is equal to one of the regex/string in $patterns, false otherwise. + */ + protected static function in_array_matches_regex($test, $patterns) + { + foreach($patterns as $val) { + if(@preg_match($val, null) === false) { + if( strcasecmp($val, $test) === 0 ) { + return true; + } + } else { + if( preg_match($val, $test) === 1 ) { + return true; + } + } + } + return false; + } + /** * Converts an array of query parameter name/value mappings into a query string. * Parameters that are in `$parametersToExclude` will not appear in the result. @@ -36,7 +62,7 @@ class UrlHelper // decode encoded square brackets $name = str_replace(array('%5B', '%5D'), array('[', ']'), $name); - if (!in_array(strtolower($name), $parametersToExclude)) { + if (!self::in_array_matches_regex(strtolower($name), $parametersToExclude)) { if (is_array($value)) { foreach ($value as $param) { if ($param === false) { |