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)
{
// 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;
}

View file

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

View file

@ -129,9 +129,10 @@ class libcalendaring_vcalendar implements Iterator
/**
* Import events from iCalendar format
*
* @param string vCalendar input
* @param string Input charset (from envelope)
* @param boolean True if parsing exceptions should be forwarded to the caller
* @param string vCalendar input
* @param string Input charset (from envelope)
* @param bool True if parsing exceptions should be forwarded to the caller
*
* @return array List of events extracted from the input
*/
public function import($vcal, $charset = 'UTF-8', $forward_exceptions = false, $memcheck = true)
@ -166,15 +167,16 @@ class libcalendaring_vcalendar implements Iterator
}
}
return array();
return [];
}
/**
* Read iCalendar events from a file
*
* @param string File path to read from
* @param string Input charset (from envelope)
* @param boolean True if parsing exceptions should be forwarded to the caller
* @param string File path to read from
* @param string Input charset (from envelope)
* @param bool True if parsing exceptions should be forwarded to the caller
*
* @return array List of events extracted from the file
*/
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) {
if (isset($this->data[$idx]) && !is_string($this->data[$idx])) {
// 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++;
}

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
*
* @return array Object properties
* @return array|false Object properties, False on error
*/
public function from_dav($object)
{
if (empty($object ) || empty($object['data'])) {
return false;
}
if ($this->type == 'event') {
$ical = libcalendaring::get_ical();
$events = $ical->import($object['data']);