diff --git a/plugins/libcalendaring/lib/Sabre/VObject/Reader.php b/plugins/libcalendaring/lib/Sabre/VObject/Reader.php index a001b2bf..0931a3d3 100644 --- a/plugins/libcalendaring/lib/Sabre/VObject/Reader.php +++ b/plugins/libcalendaring/lib/Sabre/VObject/Reader.php @@ -1,223 +1,223 @@ add($parsedLine); if ($nextLine===false) throw new ParseException('Invalid VObject. Document ended prematurely.'); } // Checking component name of the 'END:' line. if (substr($nextLine,4)!==$obj->name) { throw new ParseException('Invalid VObject, expected: "END:' . $obj->name . '" got: "' . $nextLine . '"'); } next($lines); return $obj; } // Properties //$result = preg_match('/(?P[A-Z0-9-]+)(?:;(?P^(?([^:^\"]|\"([^\"]*)\")*))?"; + $parameters = "(?:;(?P([^:\"]|\"([^\"]*)\")*))?"; $regex = "/^(?P$token)$parameters:(?P.*)$/i"; $result = preg_match($regex,$line,$matches); if (!$result) { if ($options & self::OPTION_IGNORE_INVALID_LINES) { return null; } else { throw new ParseException('Invalid VObject, line ' . ($lineNr+1) . ' did not follow the icalendar/vcard format'); } } $propertyName = strtoupper($matches['name']); $propertyValue = preg_replace_callback('#(\\\\(\\\\|N|n))#',function($matches) { if ($matches[2]==='n' || $matches[2]==='N') { return "\n"; } else { return $matches[2]; } }, $matches['value']); $obj = Property::create($propertyName, $propertyValue); if ($matches['parameters']) { foreach(self::readParameters($matches['parameters']) as $param) { $obj->add($param); } } return $obj; } /** * Reads a parameter list from a property * * This method returns an array of Parameter * * @param string $parameters * @return array */ static private function readParameters($parameters) { $token = '[A-Z0-9-]+'; $paramValue = '(?P[^\"^;]*|"[^"]*")'; $regex = "/(?<=^|;)(?P$token)(=$paramValue(?=$|;))?/i"; preg_match_all($regex, $parameters, $matches, PREG_SET_ORDER); $params = array(); foreach($matches as $match) { if (!isset($match['paramValue'])) { $value = null; } else { $value = $match['paramValue']; if (isset($value[0]) && $value[0]==='"') { // Stripping quotes, if needed $value = substr($value,1,strlen($value)-2); } $value = preg_replace_callback('#(\\\\(\\\\|N|n|;|,))#',function($matches) { if ($matches[2]==='n' || $matches[2]==='N') { return "\n"; } else { return $matches[2]; } }, $value); } $params[] = new Parameter($match['paramName'], $value); } return $params; } }