Skip to content

Commit f590d93

Browse files
committed
Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4: ext/standard: Fix convert.quoted-printable-decode of lowercase hex
2 parents 05f7a9a + 09c3e73 commit f590d93

3 files changed

Lines changed: 23 additions & 1 deletion

File tree

‎NEWS‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@ PHP NEWS
216216
. Fix persistent stream context lifetime during shutdown (Levi Morrison)
217217
. Fix wordwrap() ignoring an existing break at the end of the string
218218
(Nicolas Grekas)
219+
. Fixed convert.quoted-printable-decode decoding lowercase hex digits to
220+
the wrong byte. (Ilia Alshanetsky)
219221

220222
- Tidy:
221223
. Fixed a use-after-free when a tidyNode is used after its document is

‎ext/standard/filters.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,7 @@ static php_conv_err_t php_conv_qprint_decode_convert(php_conv_qprint_decode *ins
953953
err = PHP_CONV_ERR_INVALID_SEQ;
954954
goto out;
955955
}
956-
next_char = (next_char << 4) | (*ps >= 'A' ? *ps - 0x37 : *ps - 0x30);
956+
next_char = (next_char << 4) | (*ps >= 'a' ? *ps - 0x57 : (*ps >= 'A' ? *ps - 0x37 : *ps - 0x30));
957957
scan_stat++;
958958
ps++, icnt--;
959959
if (scan_stat != 3) {
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
convert.quoted-printable-decode: lowercase hex digits decode correctly
3+
--FILE--
4+
<?php
5+
foreach (['=cd', '=0a', '=da', '=CD', '=AB', '=ab'] as $in) {
6+
$fp = fopen('php://temp', 'r+');
7+
fwrite($fp, $in);
8+
rewind($fp);
9+
stream_filter_append($fp, 'convert.quoted-printable-decode', STREAM_FILTER_READ);
10+
echo $in, ' => ', bin2hex(stream_get_contents($fp)), "\n";
11+
fclose($fp);
12+
}
13+
?>
14+
--EXPECT--
15+
=cd => cd
16+
=0a => 0a
17+
=da => da
18+
=CD => cd
19+
=AB => ab
20+
=ab => ab

0 commit comments

Comments
 (0)