Apply NUL preprocessing to unquoted CSS URLs - #318
Merged
Conversation
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.
Recognizes unquoted CSS URLs that contain a NUL byte, so URL rewriting does not skip them.
CSS replaces NUL with U+FFFD before it decides which token to produce. The parser already applied that replacement when reading a value, but its unquoted URL check rejected the raw NUL first. This change lets that byte reach the existing decoder. See CSS input preprocessing.
Examples
<NUL>below means one zero byte in the input, not the five printed characters.url(a<NUL>b)a�b.url(a<NUL>)a�.url(a <NUL>)Other forbidden control bytes, such as
0x01, still produce bad URL tokens. The original NUL stays in the raw source and saved cursor. Source offsets therefore still refer to the original file. Unchanged CSS keeps its original bytes.Testing
The new tests cover NUL at each position in a URL, consecutive NULs, escaped NUL, EOF, CRLF, and every other forbidden ASCII control byte. Each case also runs at every possible two-chunk split, with JSON state restored between chunks.
Real-file tests use child PHP processes. They rewrite a NUL-containing URL, keep a bad URL unchanged, and continue to a later valid URL. Streaming tests place NUL at the end of the second 32 KiB read and resume after stops before and after saving state. They check the exact output, the unchanged source, and both saved file offsets.
On base commit
8e411e7c, 18 new cases fail, including all four new file-based cases. With this change, all 98 new cases pass. The full DataLiberation suite passes with 2,716 tests and 16 skips. PHP CodeSniffer passes.This PR is based on
trunkand does not depend on #314.