This commit is contained in:
the-djmaze 2022-06-28 13:41:38 +02:00
parent d6de75e3b7
commit ac7eaf3cc1
6 changed files with 16 additions and 19 deletions

View file

@ -249,7 +249,7 @@ class Component extends Node
$result = [];
foreach ($this->children as $childGroup) {
foreach ($childGroup as $child) {
if ($child instanceof Property && strtoupper($child->group) === $group) {
if ($child instanceof Property && $child->group && strtoupper($child->group) === $group) {
$result[] = $child;
}
}

View file

@ -291,6 +291,11 @@ class VCard extends VObject\Document
$this->FN = (string) $this->ORG;
$repaired = true;
// Otherwise, the NICKNAME property may work
} elseif (isset($this->NICKNAME)) {
$this->FN = (string) $this->NICKNAME;
$repaired = true;
// Otherwise, the EMAIL property may work
} elseif (isset($this->EMAIL)) {
$this->FN = (string) $this->EMAIL;

View file

@ -335,7 +335,7 @@ class Parameter extends Node
*/
public function xmlSerialize(Xml\Writer $writer)
{
foreach (is_array($this->value) ? $this->value : explode(',', $this->value) as $value) {
foreach (explode(',', $this->value) as $value) {
$writer->writeElement('text', $value);
}
}

View file

@ -53,7 +53,11 @@ class CalAddress extends Text
return $input;
}
list($schema, $everythingElse) = explode(':', $input, 2);
$schema = strtolower($schema);
if ('mailto' === $schema) {
$everythingElse = strtolower($everythingElse);
}
return strtolower($schema).':'.$everythingElse;
return $schema.':'.$everythingElse;
}
}

View file

@ -40,23 +40,11 @@ class StringUtil
*/
public static function convertToUTF8($str)
{
$encoding = mb_detect_encoding($str, ['UTF-8', 'ISO-8859-1', 'WINDOWS-1252'], true);
switch ($encoding) {
case 'ISO-8859-1':
$newStr = utf8_encode($str);
break;
/* Unreachable code. Not sure yet how we can improve this
* situation.
case 'WINDOWS-1252' :
$newStr = iconv('cp1252', 'UTF-8', $str);
break;
*/
default:
$newStr = $str;
if (!mb_check_encoding($str, 'UTF-8') && mb_check_encoding($str, 'ISO-8859-1')) {
$str = mb_convert_encoding($str, 'UTF-8', 'ISO-8859-1');
}
// Removing any control characters
return preg_replace('%(?:[\x00-\x08\x0B-\x0C\x0E-\x1F\x7F])%', '', $newStr);
return preg_replace('%(?:[\x00-\x08\x0B-\x0C\x0E-\x1F\x7F])%', '', $str);
}
}

View file

@ -14,5 +14,5 @@ class Version
/**
* Full version number.
*/
const VERSION = '4.4.1';
const VERSION = '4.4.2';
}