GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||
GeezerVison is showing github.com — [HtmlSanitizer] Accept percent-encoded line breaks and tabs in the query of hostless URLs by webdevsamran · Pull Request #65662 · symfony/symfony Conversation
|
| Q | A |
|---|---|
| Branch? | 6.4 |
| Bug fix? | yes |
| New feature? | no |
| Deprecations? | no |
| Issues | Fix #65650 |
| License | MIT |
Since the percent-decoded check for denied characters was added to UrlSanitizer::parse(), a mailto: URL with a multi-line body was rejected and the link lost its href silently. 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%0A2 is 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 \v escape 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 \v matches is listed explicitly in the pattern.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…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.
bb242a6 to
8c904f6
Compare
|
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:
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thank you @webdevsamran. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
[HtmlSanitizer] RFC 6068 multi-line mailto: URIs lose their href
There was an error while loading. Please reload this page.