/usr/share/php/Horde/Date/Parser/Handler.php is in php-horde-date-parser 2.0.6-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | <?php
class Horde_Date_Parser_Handler
{
public $pattern;
public $handlerMethod;
public function __construct($pattern, $handlerMethod)
{
$this->pattern = $pattern;
$this->handlerMethod = $handlerMethod;
}
public function match($tokens, $definitions)
{
$tokenIndex = 0;
foreach ($this->pattern as $name) {
$optional = substr($name, -1) == '?';
if ($optional) { $name = rtrim($name, '?'); }
$tag = substr($name, 0, 1) == ':';
if ($tag) {
$name = substr($name, 1);
//match = tokens[token_index] && !tokens[token_index].tags.select { |o| o.kind_of?(klass) }.empty?
$match = isset($tokens[$tokenIndex]) && $tokens[$tokenIndex]->getTag($name);
if (!$match && !$optional) { return false; }
if ($match) { $tokenIndex++; continue; }
if (!$match && $optional) { continue; }
} else {
if ($optional && $tokenIndex == count($tokens)) { return true; }
if (!isset($definitions[$name])) {
throw new Horde_Date_Parser_Exception("Invalid subset $name specified");
}
$subHandlers = $definitions[$name];
foreach ($subHandlers as $subHandler) {
if ($subHandler->match(array_slice($tokens, $tokenIndex), $definitions)) {
return true;
}
}
return false;
}
}
if ($tokenIndex != count($tokens)) { return false; }
return true;
}
}
|