Fix infinite loop in kolab_storage_dataset

This commit is contained in:
Aleksander Machniak 2022-12-09 14:39:46 +01:00
parent 748f2430cd
commit 24e2e1ce84
5 changed files with 23 additions and 11 deletions

View file

@ -2305,7 +2305,8 @@ $("#rcmfd_new_category").keypress(function(event) {
private function is_html($event) private function is_html($event)
{ {
// check for opening and closing <html> or <body> tags // check for opening and closing <html> or <body> tags
return preg_match('/<(html|body)(\s+[a-z]|>)/', $event['description'], $m) return !empty($event['description'])
&& preg_match('/<(html|body)(\s+[a-z]|>)/', $event['description'], $m)
&& strpos($event['description'], '</'.$m[1].'>') > 0; && strpos($event['description'], '</'.$m[1].'>') > 0;
} }

View file

@ -265,6 +265,10 @@ class caldav_calendar extends kolab_storage_dav_folder
} }
foreach ($this->storage->select($query) as $record) { foreach ($this->storage->select($query) as $record) {
if (empty($record)) {
continue;
}
$event = $this->_to_driver_event($record, !$virtual, false); $event = $this->_to_driver_event($record, !$virtual, false);
// remember seen categories // remember seen categories

View file

@ -131,7 +131,8 @@ class libcalendaring_vcalendar implements Iterator
* *
* @param string vCalendar input * @param string vCalendar input
* @param string Input charset (from envelope) * @param string Input charset (from envelope)
* @param boolean True if parsing exceptions should be forwarded to the caller * @param bool True if parsing exceptions should be forwarded to the caller
*
* @return array List of events extracted from the input * @return array List of events extracted from the input
*/ */
public function import($vcal, $charset = 'UTF-8', $forward_exceptions = false, $memcheck = true) public function import($vcal, $charset = 'UTF-8', $forward_exceptions = false, $memcheck = true)
@ -166,7 +167,7 @@ class libcalendaring_vcalendar implements Iterator
} }
} }
return array(); return [];
} }
/** /**
@ -174,7 +175,8 @@ class libcalendaring_vcalendar implements Iterator
* *
* @param string File path to read from * @param string File path to read from
* @param string Input charset (from envelope) * @param string Input charset (from envelope)
* @param boolean True if parsing exceptions should be forwarded to the caller * @param bool True if parsing exceptions should be forwarded to the caller
*
* @return array List of events extracted from the file * @return array List of events extracted from the file
*/ */
public function import_from_file($filepath, $charset = 'UTF-8', $forward_exceptions = false) public function import_from_file($filepath, $charset = 'UTF-8', $forward_exceptions = false)

View file

@ -132,10 +132,11 @@ class kolab_storage_dataset implements Iterator, ArrayAccess, Countable
while (isset($this->index[$idx]) && count($uids) < self::CHUNK_SIZE) { while (isset($this->index[$idx]) && count($uids) < self::CHUNK_SIZE) {
if (isset($this->data[$idx]) && !is_string($this->data[$idx])) { if (isset($this->data[$idx]) && !is_string($this->data[$idx])) {
// skip objects that had the raw content in the cache (are not empty) // skip objects that had the raw content in the cache (are not empty)
continue; }
else {
$uids[$idx] = $this->index[$idx];
} }
$uids[$idx] = $this->index[$idx];
$idx++; $idx++;
} }

View file

@ -514,10 +514,14 @@ class kolab_storage_dav_folder extends kolab_storage_folder
* *
* @param array Object data in kolab_dav_client::fetchData() format * @param array Object data in kolab_dav_client::fetchData() format
* *
* @return array Object properties * @return array|false Object properties, False on error
*/ */
public function from_dav($object) public function from_dav($object)
{ {
if (empty($object ) || empty($object['data'])) {
return false;
}
if ($this->type == 'event') { if ($this->type == 'event') {
$ical = libcalendaring::get_ical(); $ical = libcalendaring::get_ical();
$events = $ical->import($object['data']); $events = $ical->import($object['data']);