Skip to content

fix(dav): escape exception message in o:reason - #66139

Open
th-joerger wants to merge 1 commit into
nextcloud:masterfrom
th-joerger:fix/dav-reason-escape
Open

th-joerger wants to merge 1 commit into
nextcloud:masterfrom
th-joerger:fix/dav-reason-escape

Conversation

@th-joerger

@th-joerger th-joerger commented Nov 2, 2026 •

Copy link
Copy Markdown

Summary

Forbidden::serialize() and InvalidPath::serialize() passed the exception message as the value argument of DOMDocument::createElementNS(), which does not escape &. With libxml2 2.9.x this logs unterminated entity reference and sends an empty <o:reason>; with libxml2 2.13 the & is silently dropped.

The element is now created empty and the message appended as a text node, as apps/dav/lib/Exception/UidConflict.php#L76-L77 already does. The existing serialization tests for both classes get a data provider with a message containing &.

Verified end to end on 35.0.2 (PHP 8.5.12, libxml2 2.9.14): <o:reason> carries the escaped message and no warning is logged. Details in #66138.

Checklist

  • Code is properly formatted
  • Sign-off message is added to all commits
  • Tests (unit, integration, api and/or acceptance) are included
  • Documentation (manuals or wiki) has been updated or is not required
  • Backports requested where applicable (ex: critical bugfixes)
  • Labels added where applicable (ex: bug/enhancement, 3. to review, feature component)
  • Milestone added for target branch/version (ex: 32.x for stable32)

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

Fixes nextcloud#66138

Signed-off-by: Thor <thor@joerger.dev>
@th-joerger
th-joerger requested a review from a team as a code owner November 2, 2026 10:58
@th-joerger
th-joerger requested review from Altahrim, leftybournes, salmart-dev and sorbaugh and removed request for a team November 2, 2026 10:58
@th-joerger

Copy link
Copy Markdown
Author

/backport to stable35

This branch has not been deployed

No deployments
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.

[Bug]: DAV Forbidden/InvalidPath responses break on "&" in the message (DOMDocument::createElementNS(): unterminated entity reference)

1 participant