Skip to content

Add %0 format to run-tests.php #7069

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 29, 2021
Merged

Add %0 format to run-tests.php #7069

merged 1 commit into from
May 29, 2021

Conversation

nikic
Copy link
Member

@nikic nikic commented May 28, 2021

This format matches against null bytes, and prevents the test
expectation from being interpreted as binary data.

bless_tests.php will automatically replace \0 with %0 as well.

This format matches against null bytes, and prevents the test
expectation from being interpreted as binary data.

bless_tests.php will automatically replace \0 with %0 as well.
@nikic nikic force-pushed the run-tests-null branch from db3be15 to 514daed Compare May 28, 2021 12:29
@@ -589,13 +589,13 @@ PHP
PHP
PHP
-- Iteration 12 --
abcdn12340567800efgh\xijkl
abcdn12340567800efgh\xijkl
abcdn12340567800efgh\xijkl
Copy link
Member Author

@nikic nikic May 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're wondering what's going on here, it appears to be a bug in GitHub's diff viewer. The 00efgh\xijkl suffix on these lines is present in the old version as well, but GitHub doesn't display it in the side-by-side diff view.

@nikic nikic merged commit ea256a2 into php:master May 29, 2021
@TysonAndre
Copy link
Contributor

TysonAndre commented Jun 5, 2021

This will cause issues with urlencode for values such as %00 and %0a(\n) and %09(\t) https://github.com/igbinary/igbinary/blob/3.2.2/tests/igbinary_088.phpt (the run-tests diff has the same string in both)

  • Users who didn't see that thread would have a harder time figuring out why

Or for printf format strings such as printf("%012d", 1); when the format strings themselves are printed

But this is an obscure use case, and %d and %f already had this problem - it was just less often due to most binary data being ascii.

I wonder if it'd make sense to add a note to the diff output section if the actual and expected lines were exactly the same in EXPECTF sections to save time for users and answering questions about this

006+ %00%00%00%02%17%01X%14%03%11%05name0%00%11%05name1%00%11%05name2%00
006- %00%00%00%02%17%01X%14%03%11%05name0%00%11%05name1%00%11%05name2%00
006- %00%00%00%02%17%01X%14%03%11%05name0%00%11%05name1%00%11%05name2%00 (%0 means the null byte in EXPECTF in run-tests.php of php 8.1+)

(or a different symbol such as 006? (%0 means the null byte in run-tests.php of php 8.1+) for the new explanation

(and similar messages for %s, %S, %d, etc.)


I'm already switching to str_replace(['\\', '%'], ['\\\\', '\x'], urlencode($ser)) and only two test files used the combination of EXPECTF and urlencode on binary data

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.

3 participants