Repository navigation
Conversation
The token and key checks in Serializer end in `$` without the `D` modifier. In PCRE `$` also matches just before a final "\n", so a token "abc\n" or a key "key\n" passed the check, and the original value was written to the output with the newline inside the header value, e.g. "abc\n, 1" or "key\n, next=1". RFC 9651 (4.1.7, 4.1.1.3) requires serialization to fail for such values, and Parser rejects the output. Add the `D` modifier to both patterns, so `$` only matches at the very end of the value. Tests: a token, a dictionary key and a parameter key with a trailing newline must now throw SerializeException. Signed-off-by: Iefken <iefken@bughunt.dapp-normal.com>
❌ 1 Tests Failed:
View the top 1 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
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.
Fixes #77
The token and key checks in
Serializerend in$without theDmodifier, so a value with onetrailing
"\n"passed and was written into the header value unchanged ("abc\n, 1","k\n, next=1"). RFC 9651 requires serialization to fail here, andParseralready rejects theoutput.
serializeToken():/ix->/ixDserializeKey():/->/D(covers dictionary keys and parameter names)Tests (PHP 8.3, locally in a container):
SerializeItemTest::testTokenWithTrailingNewline,SerializeItemTest::testParameterKeyWithTrailingNewline,SerializeDictionaryTest::testKeyWithTrailingNewline- fail before the fix:Tests: 2975, Assertions: 3028, Failures: 3.(only these three)OK (2975 tests, 3031 assertions)[OK] No errorsphpmd analyze --ruleset phpmd.ruleset.yml):Found 0 violations and 0 errorsNot run locally: the PHP 8.1 / 8.2 / 8.4 / 8.5 / 8.6 matrix and coverage upload (the
Dmodifierexists in every supported PHP version);
composer validate(composer.json unchanged).Commit is GPG-signed and DCO signed-off.
Issue found and fixed by Claude, reproduced issue in an isolated container, then reviewed and confirmed by Ief (GitHub: iefken).
Full disclosure from my end: I am in my 'starter'-steps in learning how to find and report these kinds of bugs/issue's with the help from my (spare-) AI (-usage tokens), so any feedback is greatly appreciated aswell :)