From 5ed92533a90c2ab62887adea2dd530cdf94ef812 Mon Sep 17 00:00:00 2001 From: Christopher Szu Date: Tue, 7 Nov 2023 15:25:53 -0800 Subject: [PATCH] [INBE-269][Fix] drop malformed or illegal VALUE parameter --- lib/Document.php | 16 ++++++++-------- tests/VObject/InvalidValueParamTest.php | 23 +++++++++++++++++++++++ 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/lib/Document.php b/lib/Document.php index 7fb04c4a5..9870faac5 100644 --- a/lib/Document.php +++ b/lib/Document.php @@ -221,14 +221,14 @@ public function createProperty($name, $value = null, array $parameters = null, $ if (is_null($class)) { // If a VALUE parameter is supplied, we should use that. if (isset($parameters['VALUE'])) { - $class = $this->getClassNameForPropertyValue($parameters['VALUE']); - if (is_null($class)) { - if (in_array(strtoupper($parameters['VALUE']), $this->allowedIllegalValues, true)) { - unset($parameters['VALUE']); - $class = $this->getClassNameForPropertyName($name); - } else { - throw new InvalidDataException('Unsupported VALUE parameter for '.$name.' property. You supplied "'.$parameters['VALUE'].'"'); - } + try { + $class = $this->getClassNameForPropertyValue($parameters['VALUE']); + } catch (\Throwable $t) { + $class = null; + } + if (is_null($class)) { // VALUE is malformed or illegal, drop it + unset($parameters['VALUE']); + $class = $this->getClassNameForPropertyName($name); } } else { $class = $this->getClassNameForPropertyName($name); diff --git a/tests/VObject/InvalidValueParamTest.php b/tests/VObject/InvalidValueParamTest.php index cd069960c..07f04e7c2 100644 --- a/tests/VObject/InvalidValueParamTest.php +++ b/tests/VObject/InvalidValueParamTest.php @@ -28,4 +28,27 @@ public function testWorkaround() $doc = Reader::read($event); $this->assertEquals("LOCATION:EXAMPLE\r\n", $doc->VEVENT->LOCATION->serialize()); } + + public function testInvalidValue() + { + $event = <<assertEquals("LOCATION:Route de Boulogne\,32220 Lombez\n France", $doc->VEVENT->LOCATION->serialize()); + } }