Skip to content

Commit bc32cce

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Fix recovery of large entities in mb_decode_numericentity()
2 parents a73df8e + 91f8787 commit bc32cce

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

ext/mbstring/libmbfl/mbfl/mbfilter.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2508,12 +2508,10 @@ collector_decode_htmlnumericentity(int c, void *data)
25082508
(*pc->decoder->filter_function)(0x23, pc->decoder); /* '#' */
25092509
r = 1;
25102510
n = pc->digit;
2511-
while (n > 0) {
2511+
while (n > 1) {
25122512
r *= 10;
25132513
n--;
25142514
}
2515-
s %= r;
2516-
r /= 10;
25172515
while (r > 0) {
25182516
d = s/r;
25192517
s %= r;
@@ -2686,12 +2684,10 @@ int mbfl_filt_decode_htmlnumericentity_flush(mbfl_convert_filter *filter)
26862684
s = pc->cache;
26872685
r = 1;
26882686
n = pc->digit;
2689-
while (n > 0) {
2687+
while (n > 1) {
26902688
r *= 10;
26912689
n--;
26922690
}
2693-
s %= r;
2694-
r /= 10;
26952691
while (r > 0) {
26962692
d = s/r;
26972693
s %= r;

ext/mbstring/tests/mb_decode_numericentity.phpt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ echo mb_decode_numericentity($str1, $convmap, "UTF-8")."\n";
1515
echo mb_decode_numericentity($str2, $convmap, "UTF-8")."\n";
1616
echo mb_decode_numericentity($str3, $convmap, "UTF-8")."\n";
1717

18+
echo mb_decode_numericentity('&#1000000000', $convmap), "\n";
19+
echo mb_decode_numericentity('&#10000000000', $convmap), "\n";
20+
echo mb_decode_numericentity('&#100000000000', $convmap), "\n";
21+
1822
$convmap = [];
1923
echo mb_decode_numericentity('föo', $convmap, "UTF-8")."\n";
2024

@@ -24,10 +28,14 @@ try {
2428
} catch (ValueError $ex) {
2529
echo $ex->getMessage()."\n";
2630
}
31+
2732
?>
2833
--EXPECT--
2934
¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ
3035
ƒΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψωϑϒϖ•…′″‾⁄℘ℑℜ™ℵ←↑→↓↔↵⇐⇑⇒⇓⇔∀∂∃∅∇∈∉∋∏∑−∗√∝∞∠∧∨∩∪∫∴∼≅≈≠≡≤≥⊂⊃⊄⊆⊇⊕⊗⊥⋅⌈⌉⌊⌋〈〉◊♠♣♥♦
3136
aŒbœcŠdše€fg
37+
&#1000000000
38+
&#10000000000
39+
&#100000000000
3240
föo
3341
count($convmap) must be a multiple of 4

0 commit comments

Comments
 (0)