function _authcache_form_match_form_id in Authenticated User Page Caching (Authcache) 7.2
Check if a form_id matches any pattern in a set of patterns.
Parameters
string $form_id: The form id to match.
string $patterns: String containing a set of patterns separated by \n, \r or \r\n.
Return value
bool TRUE if the form id matches a pattern, FALSE otherwise.
See also
3 calls to _authcache_form_match_form_id()
- AuthcacheFormTestHelpers::testFormMatchFormID in modules/
authcache_form/ tests/ authcache_form.test - Cover _authcache_form_match_form_id().
- _authcache_form_allow_base_id_token in modules/
authcache_form/ authcache_form.module - Test whether CSRF token based on base form id is allowed.
- _authcache_form_allow_notoken in modules/
authcache_form/ authcache_form.module - Test whether stripping of CSRF token is allowed for the given form.
File
- modules/
authcache_form/ authcache_form.module, line 254 - Form token retrieval for Authcache.
Code
function _authcache_form_match_form_id($form_id, $patterns) {
$regexps =& drupal_static(__FUNCTION__);
if (!isset($regexps[$patterns])) {
// Convert path settings to a regular expression.
// Therefore replace newlines with a logical or and /* with asterisks.
$to_replace = array(
'/(\\r\\n?|\\n)/',
'/\\\\\\*/',
);
$replacements = array(
'|',
'.*',
);
$patterns_quoted = preg_quote($patterns, '/');
$regexps[$patterns] = '/^(' . preg_replace($to_replace, $replacements, $patterns_quoted) . ')$/';
}
return (bool) preg_match($regexps[$patterns], $form_id);
}