public function parsePath($path)
{
// no '..'
if (false !== strpos($path, '..')) {
return array();
}
// only alphanumeric characters plus /, ., -, and _
if (preg_match('#[^a-zA-Z0-9/\\.\\-_]#', $path)) {
return array();
}
// testing showed regex to be marginally faster than array / string functions over 100000 reps
// it won't make a difference in real life and regex is easier to read.
// <ts>/<viewtype>/<name/of/view.and.dots>.<type>
if (!preg_match('#^/cache/([0-9]+)/([^/]+)/(.+)$#', $path, $matches)) {
return array();
}
return array('ts' => $matches[1], 'viewtype' => $matches[2], 'view' => $matches[3]);
}