Skip to content

Fix crash when tag body contains URL-encoded characters#4086

Merged
jaapio merged 2 commits into
phpDocumentor:masterfrom
lacatoire:fix/url-encoded-description-crash
Apr 10, 2026
Merged

Fix crash when tag body contains URL-encoded characters#4086
jaapio merged 2 commits into
phpDocumentor:masterfrom
lacatoire:fix/url-encoded-description-crash

Conversation

@lacatoire

Copy link
Copy Markdown
Contributor

Summary

When a tag is invalid (e.g. @see with a non-FQSEN reference like LDAP-Error-Code), the InvalidTagAssembler creates a Description directly from the raw tag body. If the body contains URL-encoded sequences like %20, vsprintf interprets them as format specifiers and throws a ValueError.

DescriptionFactory::create() already escapes % to %% for this exact reason (line 81), but the assemblers that bypass the factory and call new Description(...) directly were missing the same escaping.

This escapes % to %% in InvalidTagAssembler, AuthorAssembler, and ExampleAssembler.

How to reproduce

/**
 * @see LDAP-Error-Code https://ldapwiki.com/wiki/Wiki.jsp?page=LDAP%20Result%20Codes
 */

Generates:

[ValueError] The arguments array must contain 2 items, 0 given

Fixes #3891

When a tag is invalid (e.g. @see with a non-FQSEN reference), the
InvalidTagAssembler creates a Description directly from the raw body.
If the body contains URL-encoded sequences like %20, vsprintf
interprets them as format specifiers and throws a ValueError.

Escape % to %% in InvalidTagAssembler, AuthorAssembler, and
ExampleAssembler to match DescriptionFactory's existing behavior.

Fixes phpDocumentor#3891
Assert on the rendered description string rather than the internal
body template, so the test actually exercises the vsprintf call that
was crashing before the fix.
@jaapio jaapio enabled auto-merge April 10, 2026 18:21
@jaapio

jaapio commented Apr 10, 2026

Copy link
Copy Markdown
Member

Thanks again, small pr's are easy to review. 👍

Please note that the invalid tag is only created because the format of the tag was incorrect. I don't know exactly what it should be. I can try to find that when you are able to change the source.

@jaapio jaapio merged commit 0fee157 into phpDocumentor:master Apr 10, 2026
116 checks passed
@lacatoire lacatoire deleted the fix/url-encoded-description-crash branch April 10, 2026 18:57
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.

Spaces in URLs cause parsing to crash due to escaping

2 participants