Changeset View
Changeset View
Standalone View
Standalone View
src/applications/calendar/parser/ics/PhutilICSParser.php
Context not available. | |||||
foreach ($lines as $key => $line) { | foreach ($lines as $key => $line) { | ||||
$this->cursor = $key; | $this->cursor = $key; | ||||
$matches = null; | $matches = null; | ||||
if (preg_match('(^BEGIN:(.*)\z)', $line, $matches)) { | if (@preg_match('(^BEGIN:(.*)\z)', $line, $matches)) { | ||||
$this->beginParsingNode($matches[1]); | $this->beginParsingNode($matches[1]); | ||||
} else if (preg_match('(^END:(.*)\z)', $line, $matches)) { | } else if (@preg_match('(^END:(.*)\z)', $line, $matches)) { | ||||
$this->endParsingNode($matches[1]); | $this->endParsingNode($matches[1]); | ||||
} else { | } else { | ||||
if (count($this->stack) < 2) { | if (count($this->stack) < 2) { | ||||
Context not available. | |||||
$last = null; | $last = null; | ||||
foreach ($lines as $idx => $line) { | foreach ($lines as $idx => $line) { | ||||
$this->cursor = $idx; | $this->cursor = $idx; | ||||
if (!preg_match('/^[ \t]/', $line)) { | if (!@preg_match('/^[ \t]/', $line)) { | ||||
$last = $idx; | $last = $idx; | ||||
continue; | continue; | ||||
} | } | ||||
Context not available. | |||||
'marks a line which should be unfolded.')); | 'marks a line which should be unfolded.')); | ||||
} | } | ||||
$lines[$last] = $lines[$last].substr($line, 1); | $lines[$last] = $lines[$last].@substr($line, 1); | ||||
unset($lines[$idx]); | unset($lines[$idx]); | ||||
} | } | ||||
Context not available. | |||||
// by either a ";" (to begin a list of parameters) or a ":" (to begin | // by either a ";" (to begin a list of parameters) or a ":" (to begin | ||||
// the actual field body). | // the actual field body). | ||||
$ok = preg_match('(^([A-Za-z0-9-]+)([;:])(.*)\z)', $line, $matches); | $ok = @preg_match('(^([A-Za-z0-9-]+)([;:])(.*)\z)', $line, $matches); | ||||
if (!$ok) { | if (!$ok) { | ||||
$this->raiseParseFailure( | $this->raiseParseFailure( | ||||
self::PARSE_MALFORMED_PROPERTY, | self::PARSE_MALFORMED_PROPERTY, | ||||
Context not available. | |||||
while (true) { | while (true) { | ||||
// We're going to get the first couple of parts first. | // We're going to get the first couple of parts first. | ||||
$ok = preg_match('(^([^=]+)=)', $body, $matches); | $ok = @preg_match('(^([^=]+)=)', $body, $matches); | ||||
if (!$ok) { | if (!$ok) { | ||||
$this->raiseParseFailure( | $this->raiseParseFailure( | ||||
self::PARSE_MALFORMED_PARAMETER_NAME, | self::PARSE_MALFORMED_PARAMETER_NAME, | ||||
Context not available. | |||||
} | } | ||||
$param_name = $matches[1]; | $param_name = $matches[1]; | ||||
$body = substr($body, strlen($matches[0])); | $body = @substr($body, @strlen($matches[0])); | ||||
// Now we're going to match zero or more values. | // Now we're going to match zero or more values. | ||||
$param_values = array(); | $param_values = array(); | ||||
while (true) { | while (true) { | ||||
// The value can either be a double-quoted string or an unquoted | // The value can either be a double-quoted string or an unquoted | ||||
// string, with some characters forbidden. | // string, with some characters forbidden. | ||||
if (strlen($body) && $body[0] == '"') { | if (@strlen($body) && $body[0] == '"') { | ||||
$is_quoted = true; | $is_quoted = true; | ||||
$ok = preg_match( | $ok = @preg_match( | ||||
'(^"([^\x00-\x08\x10-\x19"]*)")', | '(^"([^\x00-\x08\x10-\x19"]*)")', | ||||
$body, | $body, | ||||
$matches); | $matches); | ||||
Context not available. | |||||
// It's impossible for this not to match since it can match | // It's impossible for this not to match since it can match | ||||
// nothing, and it's valid for it to match nothing. | // nothing, and it's valid for it to match nothing. | ||||
preg_match('(^([^\x00-\x08\x10-\x19";:,]*))', $body, $matches); | @preg_match('(^([^\x00-\x08\x10-\x19";:,]*))', $body, $matches); | ||||
} | } | ||||
// NOTE: RFC5545 says "Property parameter values that are not in | // NOTE: RFC5545 says "Property parameter values that are not in | ||||
Context not available. | |||||
'quoted' => $is_quoted, | 'quoted' => $is_quoted, | ||||
); | ); | ||||
$body = substr($body, strlen($matches[0])); | $body = @substr($body, @strlen($matches[0])); | ||||
if (!strlen($body)) { | if (!@strlen($body)) { | ||||
$this->raiseParseFailure( | $this->raiseParseFailure( | ||||
self::PARSE_MISSING_VALUE, | self::PARSE_MISSING_VALUE, | ||||
pht( | pht( | ||||
Context not available. | |||||
// If we have a comma now, we're going to read another value. Strip | // If we have a comma now, we're going to read another value. Strip | ||||
// it off and keep going. | // it off and keep going. | ||||
if ($body[0] == ',') { | if ($body[0] == ',') { | ||||
$body = substr($body, 1); | $body = @substr($body, 1); | ||||
continue; | continue; | ||||
} | } | ||||
Context not available. | |||||
); | ); | ||||
if ($body[0] == ';') { | if ($body[0] == ';') { | ||||
$body = substr($body, 1); | $body = @substr($body, 1); | ||||
continue; | continue; | ||||
} | } | ||||
if ($body[0] == ':') { | if ($body[0] == ':') { | ||||
$body = substr($body, 1); | $body = @substr($body, 1); | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
Context not available. | |||||
break; | break; | ||||
case 'DATE': | case 'DATE': | ||||
// This is a comma-separated list of "YYYYMMDD" values. | // This is a comma-separated list of "YYYYMMDD" values. | ||||
$result = explode(',', $data); | $result = @explode(',', $data); | ||||
break; | break; | ||||
case 'DATE-TIME': | case 'DATE-TIME': | ||||
if (!strlen($data)) { | if (!@strlen($data)) { | ||||
$result = array(); | $result = array(); | ||||
} else { | } else { | ||||
$result = explode(',', $data); | $result = @explode(',', $data); | ||||
} | } | ||||
break; | break; | ||||
case 'DURATION': | case 'DURATION': | ||||
if (!strlen($data)) { | if (!@strlen($data)) { | ||||
$result = array(); | $result = array(); | ||||
} else { | } else { | ||||
$result = explode(',', $data); | $result = @explode(',', $data); | ||||
} | } | ||||
break; | break; | ||||
case 'FLOAT': | case 'FLOAT': | ||||
$result = explode(',', $data); | $result = @explode(',', $data); | ||||
foreach ($result as $k => $v) { | foreach ($result as $k => $v) { | ||||
$result[$k] = (float)$v; | $result[$k] = (float)$v; | ||||
} | } | ||||
break; | break; | ||||
case 'INTEGER': | case 'INTEGER': | ||||
$result = explode(',', $data); | $result = @explode(',', $data); | ||||
foreach ($result as $k => $v) { | foreach ($result as $k => $v) { | ||||
$result[$k] = (int)$v; | $result[$k] = (int)$v; | ||||
} | } | ||||
break; | break; | ||||
case 'PERIOD': | case 'PERIOD': | ||||
$result = explode(',', $data); | $result = @explode(',', $data); | ||||
break; | break; | ||||
case 'RECUR': | case 'RECUR': | ||||
$result = $data; | $result = $data; | ||||
Context not available. | |||||
$result = $this->unescapeTextValue($data); | $result = $this->unescapeTextValue($data); | ||||
break; | break; | ||||
case 'TIME': | case 'TIME': | ||||
$result = explode(',', $data); | $result = @explode(',', $data); | ||||
break; | break; | ||||
case 'URI': | case 'URI': | ||||
$result = $data; | $result = $data; | ||||
Context not available. | |||||
$value = head($value); | $value = head($value); | ||||
$tzid = $this->getScalarParameterValue($parameters, 'TZID'); | $tzid = $this->getScalarParameterValue($parameters, 'TZID'); | ||||
if (preg_match('/Z\z/', $value)) { | if (@preg_match('/Z\z/', $value)) { | ||||
if ($tzid) { | if ($tzid) { | ||||
$this->raiseWarning( | $this->raiseWarning( | ||||
self::WARN_TZID_UTC, | self::WARN_TZID_UTC, | ||||
Context not available. | |||||
'/i'; | '/i'; | ||||
$matches = null; | $matches = null; | ||||
if (preg_match($offset_pattern, $tzid, $matches)) { | if (@preg_match($offset_pattern, $tzid, $matches)) { | ||||
$hours = (int)$matches['h']; | $hours = (int)$matches['h']; | ||||
$minutes = (int)idx($matches, 'm'); | $minutes = (int)idx($matches, 'm'); | ||||
$offset = ($hours * 60 * 60) + ($minutes * 60); | $offset = ($hours * 60 * 60) + ($minutes * 60); | ||||
Context not available. |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0