-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix #76954 Use while loop in func add_response_header #3566
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
Fix #76954 Use while loop in func add_response_header #3566
Conversation
Could you add a unit test? |
Indeed, the refactoring in 4cba2f9 looks fishy. If Regarding the unit test: I'm not sure if we can use the |
Regarding to do ... while, possible solution is: if (NULL != p) {
len = p - h->header + 1;
}
if (len > 0) {
do {
len--;
} while (len != 0 && (h->header[len-1] == ' ' || h->header[len-1] == '\t')); It works fine even if @cmb69 If we use if (NULL != p) {
len = p - h->header;
}
if (len > 0) {
do {
len--;
} while (len != 0 && (h->header[len] == ' ' || h->header[len] == '\t'));
if (len) {
len++; // Include last character. If I've added test and we don't need |
@stodorovic Thanks, that sounds plausible. (And yes, I've confused |
|
||
passthru("$php -n -q $filename"); | ||
|
||
@unlink($filename); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be in a --CLEAN-- section for consistency
|
||
file_put_contents($filename, $code); | ||
|
||
passthru("$php -n -q $filename"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is a full path (from the $filename variable), the $filename should be quoted for escapes in case the full path contains a space
Comment on behalf of cmb at php.net: Thanks! Applied via 47b89bc. |
Related issues:
https://bugs.php.net/bug.php?id=76954
https://github.com/Automattic/wp-super-cache/issues/539
PHP 5.6 uses while loop, but PHP 7.x uses do ... while which decreases
len
before condition. Parameterlen
in functionmemcpy
has decreased length and last character isn't copied.