Skip to content

fix: do not crash on a repeated or listed VALUE parameter - #795

Open
odolbeau wants to merge 2 commits into
sabre-io:masterfrom
odolbeau:fix/repeated-value-parameter
Open

odolbeau wants to merge 2 commits into
sabre-io:masterfrom
odolbeau:fix/repeated-value-parameter

Conversation

@odolbeau

@odolbeau odolbeau commented Oct 2, 2026 •

Copy link
Copy Markdown

Fixes #635.

RFC 6350 and RFC 5545 allow a single value type in the VALUE parameter, but some producers write several. ez-vcard does it in two ways:

PRODID;VALUE=text;VALUE=TEXT:ez-vcard 0.12.1
URL;VALUE=uri,text:https://jane.example

In both cases, the MIME-dir parser hands createProperty() an array for VALUE. getClassNameForPropertyValue() only accepts a string, so reading the whole document fails:

TypeError: Sabre\VObject\Document::getClassNameForPropertyValue(): Argument #1 ($valueParam) must be of type string, array given

With this fix, createProperty() uses the first value of a repeated or listed VALUE parameter to pick the property class. The parameter itself is kept as is, so the document serializes back unchanged.

Tests:

  • DocumentTest::testCreatePropertyWithRepeatedValueParameter: createProperty() with an array for VALUE.
  • ReaderTest::testReadPropertyWithRepeatedValueParameter: reading the PRODID line above.
  • ReaderTest::testReadPropertyWithListedValueParameter: reading the URL line above, and serializing it back.

The three fail with the TypeError above without the fix.

Some producers repeat the VALUE parameter, such as ez-vcard with
PRODID;VALUE=text;VALUE=TEXT. The parser then passes an array to
createProperty(), and getClassNameForPropertyValue() throws a TypeError.
Use the first value to pick the property class.

Fixes sabre-io#635

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ez-vcard also writes several value types in a single VALUE parameter
(URL;VALUE=uri,text:...). The parser hands createProperty() the same
array as for a repeated VALUE, so the same fix applies: test it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@odolbeau odolbeau changed the title fix: do not crash on a repeated VALUE parameter fix: do not crash on a repeated or listed VALUE parameter Oct 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

createProperty: check if parameter VALUE is a string

1 participant