summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
authorCasey Hancock <crh431@gmail.com>2014-08-11 18:52:20 +0200
committerCasey Hancock <crh431@gmail.com>2014-08-11 18:52:20 +0200
commit2f4c3bc5c2fac164d1c58ac9aaa09ae070687443 (patch)
tree521444d05bbf0dbb43f589228402a26907e5fb41 /system
parent09546edca0645af6002caa00a2f9b7eaaae38f17 (diff)
CSRF whitelist supports regex
Signed-off-by: Casey Hancock <crh431@gmail.com>
Diffstat (limited to 'system')
-rwxr-xr-xsystem/core/Security.php11
1 files changed, 7 insertions, 4 deletions
diff --git a/system/core/Security.php b/system/core/Security.php
index 741ff229b..a6fd75fa4 100755
--- a/system/core/Security.php
+++ b/system/core/Security.php
@@ -203,10 +203,13 @@ class CI_Security {
if ($exclude_uris = config_item('csrf_exclude_uris'))
{
$uri = load_class('URI', 'core');
- if (in_array($uri->uri_string(), $exclude_uris))
- {
- return $this;
- }
+ foreach ($exclude_uris as $excluded) {
+ $excluded = str_replace(array(':any', ':num'), array('[^/]+', '[0-9]+'), $excluded);
+ if (preg_match('#^'.$excluded.'$#', $uri->uri_string()))
+ {
+ return $this;
+ }
+ }
}
// Do the tokens exist in both the _POST and _COOKIE arrays?