Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[INBE-269][Fix] drop malformed or illegal VALUE parameter #92

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 6 additions & 18 deletions lib/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,6 @@ abstract class Document extends Component
*/
public static $valueMap = [];

/**
* List of RFC violating values that we allow in parameter value.
* e.g. LOCATION;VALUE=ERROR:some location
*
* @var string[]
*/
private array $allowedIllegalValues = [
'ERROR',
];

/**
* Creates a new document.
*
Expand Down Expand Up @@ -221,14 +211,12 @@ 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'].'"');
}
if (is_string($parameters['VALUE'])) {
$class = $this->getClassNameForPropertyValue($parameters['VALUE']);
giuseppe-arcuti marked this conversation as resolved.
Show resolved Hide resolved
}
if (is_null($class)) { // VALUE is malformed or illegal, drop it
unset($parameters['VALUE']);
giuseppe-arcuti marked this conversation as resolved.
Show resolved Hide resolved
$class = $this->getClassNameForPropertyName($name);
}
giuseppe-arcuti marked this conversation as resolved.
Show resolved Hide resolved
} else {
$class = $this->getClassNameForPropertyName($name);
Expand Down
23 changes: 23 additions & 0 deletions tests/VObject/InvalidValueParamTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <<<ICS
BEGIN:VCALENDAR
VERSION:2.0
BEGIN:VEVENT
DTEND;TZID=Europe/Paris:20170530T220000
DTSTAMP:20230317T130521Z
DTSTART;TZID=Europe/Paris:20170530T200000
LAST-MODIFIED:20230316T155811Z
LOCATION;VALUE=consectetur adipiscing elit, sed do eiusmod tempor:consectetur adipiscing elit\,sed do eiusmod tempor
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:Lorem ipsum dolor sit amet
UID:0171706E-00F4-4846-8B5F-7FBD474A90AC
END:VEVENT
END:VCALENDAR
ICS;

$doc = Reader::read($event);
$this->assertEquals("LOCATION:consectetur adipiscing elit\,sed do eiusmod tempor\r\n", $doc->VEVENT->LOCATION->serialize());
}
}
Loading