Repository navigation
[HtmlSanitizer] Accept percent-encoded line breaks and tabs in the query of hostless URLs - #65662
Merged
nicolas-grekas merged 1 commit intoAug 27, 2026
Conversation
…ery of hostless URLs RFC 6068 requires line breaks in the body of a mailto URL to be encoded as %0D%0A. Since the percent-decoded check for denied characters was added, such URLs were rejected and the href silently dropped. The check now ignores CR, LF and TAB in the query and fragment of hostless schemes (mailto, sms, ...) and keeps rejecting them in every other component and for every other scheme, together with the BiDi marks and the Unicode whitespace. The "\v" escape in the pattern is PCRE vertical whitespace, not the vertical tab. It is replaced by "\x0B", which changes nothing since every character "\v" matches is listed explicitly.
nicolas-grekas
requested review from
chalasr,
dunglas,
lyrixx,
xabbuh and
yceruto
as code owners
August 27, 2026 12:11
nicolas-grekas
force-pushed
the
fix/issue-65650-htmlsanitizer-mailto-rfc6068
branch
from
August 27, 2026 12:11
bb242a6 to
8c904f6
Compare
Member
|
Thank you for the fix. The scope is the right one (query and fragment of hostless schemes only), but the submitted patch did not change the outcome for the CRLF cases, which is why the two new test cases failed on CI: the new constant is a single-quoted PHP string, so PCRE receives I reworked it and pushed to your branch, retargeted to 6.4 where the check was introduced:
|
Member
|
Thank you @webdevsamran. |
This was referenced Aug 30, 2026
Merged
Merged
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since the percent-decoded check for denied characters was added to
UrlSanitizer::parse(), amailto:URL with a multi-line body was rejected and the link lost itshrefsilently. RFC 6068 requires line breaks in the body to be encoded as%0D%0A, so a URL that follows the scheme's own specification was dropped.The check now ignores percent-encoded CR, LF and TAB in the query and fragment of hostless schemes (
mailto,sms,tel, ...). Everything else is unchanged: those characters stay rejected in every other component, for every scheme with an authority (https://example.org/a?x=1%0A2is still rejected), and the BiDi marks and Unicode whitespace stay rejected everywhere, encoded or not. The output keeps the percent-encoded form.Before:
<a href="mailto:[email protected]?body=send%20current-issue%0D%0Asend%20index">contact</a>became<a>contact</a>.After:
<a href="mailto:infobot@example.com?body=send%20current-issue%0D%0Asend%20index">contact</a>.The
\vescape in the denied-characters pattern is PCRE's vertical whitespace class, not the vertical tab; it is replaced by\x0B. This changes nothing, since every character\vmatches is listed explicitly in the pattern.