Пример #1
0
 /**
  * Checks for noncompiling or dangerous regex
  * @param array $rewrite rewrite arguments to be evaluated for dangerous or noncompiling regex
  * @param string $domain the domain argument passed in the rewrite rules
  * @param string $pattern regex pattern passed in the rewrite rules
  * @param string $argmatch optional regex arg passed in rewrite rules
  * @param string $replacement rewrite rule's replacement arg
  * @param bool $quiet (Default: false) if false turns output buffering off and displays errors, true buffers outputs to keep unit-tests clean
  * @return bool $skip if true, the regex didn't compile or dangerous regex was found and this rewrite will be skipped, if true the regex was safe
  */
 public static function is_scary_regex($rewrite, $domain, $pattern, $argmatch, $replacement, $quiet = false)
 {
     $filterees = array($domain, $pattern, $argmatch);
     $skip = false;
     foreach ($filterees as $key) {
         if (!isset($rewrite[$key])) {
             continue;
         }
         if (!Patterns::check_for_noncompiled_regex_string($rewrite[$key], $quiet)) {
             $skip = true;
         }
         if (!Patterns::reject_dangerous_regex_string($rewrite[$key], $quiet)) {
             $skip = true;
         }
     }
     if (!Patterns::reject_dangerous_regex_string($rewrite[$replacement], $quiet)) {
         $skip = true;
     }
     return $skip;
 }