Skip to content

Commit 386c9d3

Browse files
committed
Merge branch 'master' into preload
* master: Optimize substr() edge-case conditions [ci skip] Update UPGRADING Fix #71592: External entity processing never fails Add TIDY_TAG_* constants supported by libtidy 5 Add is_iterable to opcache Optimizer
2 parents d7fbb4d + 359f19e commit 386c9d3

File tree

7 files changed

+139
-41
lines changed

7 files changed

+139
-41
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,7 @@ PHP NEWS
3838
. Fixed bug #76737 (Unserialized reflection objects are broken, they
3939
shouldn't be serializable). (Nikita)
4040

41+
- Tidy:
42+
. Added TIDY_TAG_* constants for HTML5 elements. (cmb)
43+
4144
<<< NOTE: Insert NEWS from last stable release here prior to actual release! >>>

UPGRADING

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,36 @@ PHP 7.4 UPGRADE NOTES
122122
10. New Global Constants
123123
========================================
124124

125+
- Tidy:
126+
. TIDY_TAG_ARTICLE
127+
. TIDY_TAG_ASIDE
128+
. TIDY_TAG_AUDIO
129+
. TIDY_TAG_BDI
130+
. TIDY_TAG_CANVAS
131+
. TIDY_TAG_COMMAND
132+
. TIDY_TAG_DATALIST
133+
. TIDY_TAG_DETAILS
134+
. TIDY_TAG_DIALOG
135+
. TIDY_TAG_FIGCAPTION
136+
. TIDY_TAG_FIGURE
137+
. TIDY_TAG_FOOTER
138+
. TIDY_TAG_HEADER
139+
. TIDY_TAG_HGROUP
140+
. TIDY_TAG_MAIN
141+
. TIDY_TAG_MARK
142+
. TIDY_TAG_MENUITEM
143+
. TIDY_TAG_METER
144+
. TIDY_TAG_NAV
145+
. TIDY_TAG_OUTPUT
146+
. TIDY_TAG_PROGRESS
147+
. TIDY_TAG_SECTION
148+
. TIDY_TAG_SOURCE
149+
. TIDY_TAG_SUMMARY
150+
. TIDY_TAG_TEMPLATE
151+
. TIDY_TAG_TIME
152+
. TIDY_TAG_TRACK
153+
. TIDY_TAG_VIDEO
154+
125155
========================================
126156
11. Changes to INI File Handling
127157
========================================

ext/opcache/Optimizer/zend_func_info.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,7 @@ static const func_info_t func_infos[] = {
606606
F0("is_scalar", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_TRUE),
607607
F0("is_callable", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_TRUE),
608608
F0("is_countable", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_TRUE),
609+
F0("is_iterable", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_TRUE),
609610
F0("pclose", MAY_BE_FALSE | MAY_BE_LONG),
610611
F1("popen", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_RESOURCE),
611612
F0("readfile", MAY_BE_FALSE | MAY_BE_LONG),

ext/standard/string.c

Lines changed: 41 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2415,52 +2415,53 @@ PHP_FUNCTION(substr)
24152415
Z_PARAM_LONG(l)
24162416
ZEND_PARSE_PARAMETERS_END();
24172417

2418-
if (argc > 2) {
2419-
if ((l < 0 && (size_t)(-l) > ZSTR_LEN(str))) {
2420-
RETURN_FALSE;
2421-
} else if (l > (zend_long)ZSTR_LEN(str)) {
2422-
l = ZSTR_LEN(str);
2423-
}
2424-
} else {
2425-
l = ZSTR_LEN(str);
2426-
}
2427-
24282418
if (f > (zend_long)ZSTR_LEN(str)) {
24292419
RETURN_FALSE;
2430-
} else if (f < 0 && (size_t)-f > ZSTR_LEN(str)) {
2431-
f = 0;
2432-
}
2433-
2434-
if (l < 0 && (l + (zend_long)ZSTR_LEN(str) - f) < 0) {
2435-
RETURN_FALSE;
2436-
}
2437-
2438-
/* if "from" position is negative, count start position from the end
2439-
* of the string
2440-
*/
2441-
if (f < 0) {
2442-
f = (zend_long)ZSTR_LEN(str) + f;
2443-
if (f < 0) {
2420+
} else if (f < 0) {
2421+
/* if "from" position is negative, count start position from the end
2422+
* of the string
2423+
*/
2424+
if ((size_t)-f > ZSTR_LEN(str)) {
24442425
f = 0;
2426+
} else {
2427+
f = (zend_long)ZSTR_LEN(str) + f;
24452428
}
2446-
}
2447-
2448-
/* if "length" position is negative, set it to the length
2449-
* needed to stop that many chars from the end of the string
2450-
*/
2451-
if (l < 0) {
2452-
l = ((zend_long)ZSTR_LEN(str) - f) + l;
2429+
if (argc > 2) {
2430+
if (l < 0) {
2431+
/* if "length" position is negative, set it to the length
2432+
* needed to stop that many chars from the end of the string
2433+
*/
2434+
if ((size_t)(-l) > ZSTR_LEN(str) - (size_t)f) {
2435+
if ((size_t)(-l) > ZSTR_LEN(str)) {
2436+
RETURN_FALSE;
2437+
} else {
2438+
l = 0;
2439+
}
2440+
} else {
2441+
l = (zend_long)ZSTR_LEN(str) - f + l;
2442+
}
2443+
} else if ((size_t)l > ZSTR_LEN(str) - (size_t)f) {
2444+
goto truncate_len;
2445+
}
2446+
} else {
2447+
goto truncate_len;
2448+
}
2449+
} else if (argc > 2) {
24532450
if (l < 0) {
2454-
l = 0;
2451+
/* if "length" position is negative, set it to the length
2452+
* needed to stop that many chars from the end of the string
2453+
*/
2454+
if ((size_t)(-l) > ZSTR_LEN(str) - (size_t)f) {
2455+
RETURN_FALSE;
2456+
} else {
2457+
l = (zend_long)ZSTR_LEN(str) - f + l;
2458+
}
2459+
} else if ((size_t)l > ZSTR_LEN(str) - (size_t)f) {
2460+
goto truncate_len;
24552461
}
2456-
}
2457-
2458-
if (f > (zend_long)ZSTR_LEN(str)) {
2459-
RETURN_FALSE;
2460-
}
2461-
2462-
if ((size_t)l > ZSTR_LEN(str) - (size_t)f) {
2463-
l = ZSTR_LEN(str) - f;
2462+
} else {
2463+
truncate_len:
2464+
l = (zend_long)ZSTR_LEN(str) - f;
24642465
}
24652466

24662467
if (l == 0) {

ext/tidy/tidy.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2021,6 +2021,36 @@ static void _php_tidy_register_tags(INIT_FUNC_ARGS)
20212021
TIDY_TAG_CONST(VAR);
20222022
TIDY_TAG_CONST(WBR);
20232023
TIDY_TAG_CONST(XMP);
2024+
# if HAVE_TIDYBUFFIO_H
2025+
TIDY_TAG_CONST(ARTICLE);
2026+
TIDY_TAG_CONST(ASIDE);
2027+
TIDY_TAG_CONST(AUDIO);
2028+
TIDY_TAG_CONST(BDI);
2029+
TIDY_TAG_CONST(CANVAS);
2030+
TIDY_TAG_CONST(COMMAND);
2031+
TIDY_TAG_CONST(DATALIST);
2032+
TIDY_TAG_CONST(DETAILS);
2033+
TIDY_TAG_CONST(DIALOG);
2034+
TIDY_TAG_CONST(FIGCAPTION);
2035+
TIDY_TAG_CONST(FIGURE);
2036+
TIDY_TAG_CONST(FOOTER);
2037+
TIDY_TAG_CONST(HEADER);
2038+
TIDY_TAG_CONST(HGROUP);
2039+
TIDY_TAG_CONST(MAIN);
2040+
TIDY_TAG_CONST(MARK);
2041+
TIDY_TAG_CONST(MENUITEM);
2042+
TIDY_TAG_CONST(METER);
2043+
TIDY_TAG_CONST(NAV);
2044+
TIDY_TAG_CONST(OUTPUT);
2045+
TIDY_TAG_CONST(PROGRESS);
2046+
TIDY_TAG_CONST(SECTION);
2047+
TIDY_TAG_CONST(SOURCE);
2048+
TIDY_TAG_CONST(SUMMARY);
2049+
TIDY_TAG_CONST(TEMPLATE);
2050+
TIDY_TAG_CONST(TIME);
2051+
TIDY_TAG_CONST(TRACK);
2052+
TIDY_TAG_CONST(VIDEO);
2053+
# endif
20242054
}
20252055

20262056
#endif

ext/xml/compat.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,10 @@ _external_entity_ref_handler(void *user, const xmlChar *names, int type, const x
359359
return;
360360
}
361361

362-
parser->h_external_entity_ref(parser, names, (XML_Char *) "", sys_id, pub_id);
362+
if (!parser->h_external_entity_ref(parser, names, (XML_Char *) "", sys_id, pub_id)) {
363+
xmlStopParser(parser->parser);
364+
parser->parser->errNo = XML_ERROR_EXTERNAL_ENTITY_HANDLING;
365+
};
363366
}
364367

365368
static xmlEntityPtr

ext/xml/tests/bug71592.phpt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
--TEST--
2+
Bug #71592 (External entity processing never fails)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('xml')) die('skip xml extension not available');
6+
?>
7+
--FILE--
8+
<?php
9+
$xml = <<<XML
10+
<?xml version="1.0" encoding="UTF-8"?>
11+
<!DOCTYPE p [
12+
<!ENTITY pic PUBLIC "image.gif" "http://example.org/image.gif">
13+
]>
14+
<root>
15+
<p>&pic;</p>
16+
<p></nop>
17+
</root>
18+
XML;
19+
20+
$parser = xml_parser_create_ns('UTF-8');
21+
xml_set_external_entity_ref_handler($parser, function () {
22+
return false;
23+
});
24+
xml_parse($parser, $xml);
25+
var_dump(xml_get_error_code($parser));
26+
?>
27+
===DONE===
28+
--EXPECT--
29+
int(21)
30+
===DONE===

0 commit comments

Comments
 (0)