Skip to content

Commit bd8a9bd

Browse files
committed
Fix GH-22360: convert.base64-encode corruption on incremental flush.
Fix #22360 close GH-22368
1 parent df7fd97 commit bd8a9bd

3 files changed

Lines changed: 29 additions & 1 deletion

File tree

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ PHP NEWS
66
. Fixed bug GH-22324 (Ignore leading namespace separator in
77
ReflectionParameter::__construct()). (jorgsowa)
88

9+
- Standard:
10+
. Fixed bug GH-22360 (convert.base64-encode corruption on
11+
incremental flush). (David Carlier)
12+
913
02 Jul 2026, PHP 8.4.23
1014

1115
- Core:

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)