Skip to content

Commit e601337

Browse files
committed
Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4: Fix phpGH-22360: convert.base64-encode corruption on incremental flush.
2 parents 91ceed7 + bd8a9bd commit e601337

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

ext/standard/filters.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1519,7 +1519,7 @@ static php_stream_filter_status_t strfilter_convert_filter(
15191519
php_stream_bucket_delref(bucket);
15201520
}
15211521

1522-
if (flags != PSFS_FLAG_NORMAL) {
1522+
if (flags & PSFS_FLAG_FLUSH_CLOSE) {
15231523
if (strfilter_convert_append_bucket(inst, stream, thisfilter,
15241524
buckets_out, NULL, 0, &consumed,
15251525
php_stream_is_persistent(stream)) != SUCCESS) {
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
GH-22360 (convert.base64-encode emits padding on incremental flush)
3+
--FILE--
4+
<?php
5+
$file = __DIR__ . '/gh22360.tmp';
6+
$fp = fopen($file, 'w');
7+
stream_filter_append($fp, 'convert.base64-encode', STREAM_FILTER_WRITE);
8+
9+
fwrite($fp, "ab");
10+
fflush($fp);
11+
fwrite($fp, "c");
12+
fflush($fp);
13+
fclose($fp);
14+
15+
var_dump(file_get_contents($file));
16+
echo base64_encode("abc"), PHP_EOL;
17+
?>
18+
--CLEAN--
19+
<?php
20+
@unlink(__DIR__ . '/gh22360.tmp');
21+
?>
22+
--EXPECT--
23+
string(4) "YWJj"
24+
YWJj

0 commit comments

Comments
 (0)