mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
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
This commit is contained in:
commit
386c9d3470
7 changed files with 143 additions and 45 deletions
3
NEWS
3
NEWS
|
@ -38,4 +38,7 @@ PHP NEWS
|
|||
. Fixed bug #76737 (Unserialized reflection objects are broken, they
|
||||
shouldn't be serializable). (Nikita)
|
||||
|
||||
- Tidy:
|
||||
. Added TIDY_TAG_* constants for HTML5 elements. (cmb)
|
||||
|
||||
<<< NOTE: Insert NEWS from last stable release here prior to actual release! >>>
|
||||
|
|
30
UPGRADING
30
UPGRADING
|
@ -122,6 +122,36 @@ PHP 7.4 UPGRADE NOTES
|
|||
10. New Global Constants
|
||||
========================================
|
||||
|
||||
- Tidy:
|
||||
. TIDY_TAG_ARTICLE
|
||||
. TIDY_TAG_ASIDE
|
||||
. TIDY_TAG_AUDIO
|
||||
. TIDY_TAG_BDI
|
||||
. TIDY_TAG_CANVAS
|
||||
. TIDY_TAG_COMMAND
|
||||
. TIDY_TAG_DATALIST
|
||||
. TIDY_TAG_DETAILS
|
||||
. TIDY_TAG_DIALOG
|
||||
. TIDY_TAG_FIGCAPTION
|
||||
. TIDY_TAG_FIGURE
|
||||
. TIDY_TAG_FOOTER
|
||||
. TIDY_TAG_HEADER
|
||||
. TIDY_TAG_HGROUP
|
||||
. TIDY_TAG_MAIN
|
||||
. TIDY_TAG_MARK
|
||||
. TIDY_TAG_MENUITEM
|
||||
. TIDY_TAG_METER
|
||||
. TIDY_TAG_NAV
|
||||
. TIDY_TAG_OUTPUT
|
||||
. TIDY_TAG_PROGRESS
|
||||
. TIDY_TAG_SECTION
|
||||
. TIDY_TAG_SOURCE
|
||||
. TIDY_TAG_SUMMARY
|
||||
. TIDY_TAG_TEMPLATE
|
||||
. TIDY_TAG_TIME
|
||||
. TIDY_TAG_TRACK
|
||||
. TIDY_TAG_VIDEO
|
||||
|
||||
========================================
|
||||
11. Changes to INI File Handling
|
||||
========================================
|
||||
|
|
|
@ -606,6 +606,7 @@ static const func_info_t func_infos[] = {
|
|||
F0("is_scalar", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_TRUE),
|
||||
F0("is_callable", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_TRUE),
|
||||
F0("is_countable", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_TRUE),
|
||||
F0("is_iterable", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_TRUE),
|
||||
F0("pclose", MAY_BE_FALSE | MAY_BE_LONG),
|
||||
F1("popen", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_RESOURCE),
|
||||
F0("readfile", MAY_BE_FALSE | MAY_BE_LONG),
|
||||
|
|
|
@ -2415,52 +2415,53 @@ PHP_FUNCTION(substr)
|
|||
Z_PARAM_LONG(l)
|
||||
ZEND_PARSE_PARAMETERS_END();
|
||||
|
||||
if (argc > 2) {
|
||||
if ((l < 0 && (size_t)(-l) > ZSTR_LEN(str))) {
|
||||
RETURN_FALSE;
|
||||
} else if (l > (zend_long)ZSTR_LEN(str)) {
|
||||
l = ZSTR_LEN(str);
|
||||
}
|
||||
} else {
|
||||
l = ZSTR_LEN(str);
|
||||
}
|
||||
|
||||
if (f > (zend_long)ZSTR_LEN(str)) {
|
||||
RETURN_FALSE;
|
||||
} else if (f < 0 && (size_t)-f > ZSTR_LEN(str)) {
|
||||
f = 0;
|
||||
}
|
||||
|
||||
if (l < 0 && (l + (zend_long)ZSTR_LEN(str) - f) < 0) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
} else if (f < 0) {
|
||||
/* if "from" position is negative, count start position from the end
|
||||
* of the string
|
||||
*/
|
||||
if (f < 0) {
|
||||
f = (zend_long)ZSTR_LEN(str) + f;
|
||||
if (f < 0) {
|
||||
if ((size_t)-f > ZSTR_LEN(str)) {
|
||||
f = 0;
|
||||
} else {
|
||||
f = (zend_long)ZSTR_LEN(str) + f;
|
||||
}
|
||||
}
|
||||
|
||||
if (argc > 2) {
|
||||
if (l < 0) {
|
||||
/* if "length" position is negative, set it to the length
|
||||
* needed to stop that many chars from the end of the string
|
||||
*/
|
||||
if (l < 0) {
|
||||
l = ((zend_long)ZSTR_LEN(str) - f) + l;
|
||||
if (l < 0) {
|
||||
if ((size_t)(-l) > ZSTR_LEN(str) - (size_t)f) {
|
||||
if ((size_t)(-l) > ZSTR_LEN(str)) {
|
||||
RETURN_FALSE;
|
||||
} else {
|
||||
l = 0;
|
||||
}
|
||||
} else {
|
||||
l = (zend_long)ZSTR_LEN(str) - f + l;
|
||||
}
|
||||
|
||||
if (f > (zend_long)ZSTR_LEN(str)) {
|
||||
} else if ((size_t)l > ZSTR_LEN(str) - (size_t)f) {
|
||||
goto truncate_len;
|
||||
}
|
||||
} else {
|
||||
goto truncate_len;
|
||||
}
|
||||
} else if (argc > 2) {
|
||||
if (l < 0) {
|
||||
/* if "length" position is negative, set it to the length
|
||||
* needed to stop that many chars from the end of the string
|
||||
*/
|
||||
if ((size_t)(-l) > ZSTR_LEN(str) - (size_t)f) {
|
||||
RETURN_FALSE;
|
||||
} else {
|
||||
l = (zend_long)ZSTR_LEN(str) - f + l;
|
||||
}
|
||||
|
||||
if ((size_t)l > ZSTR_LEN(str) - (size_t)f) {
|
||||
l = ZSTR_LEN(str) - f;
|
||||
} else if ((size_t)l > ZSTR_LEN(str) - (size_t)f) {
|
||||
goto truncate_len;
|
||||
}
|
||||
} else {
|
||||
truncate_len:
|
||||
l = (zend_long)ZSTR_LEN(str) - f;
|
||||
}
|
||||
|
||||
if (l == 0) {
|
||||
|
|
|
@ -2021,6 +2021,36 @@ static void _php_tidy_register_tags(INIT_FUNC_ARGS)
|
|||
TIDY_TAG_CONST(VAR);
|
||||
TIDY_TAG_CONST(WBR);
|
||||
TIDY_TAG_CONST(XMP);
|
||||
# if HAVE_TIDYBUFFIO_H
|
||||
TIDY_TAG_CONST(ARTICLE);
|
||||
TIDY_TAG_CONST(ASIDE);
|
||||
TIDY_TAG_CONST(AUDIO);
|
||||
TIDY_TAG_CONST(BDI);
|
||||
TIDY_TAG_CONST(CANVAS);
|
||||
TIDY_TAG_CONST(COMMAND);
|
||||
TIDY_TAG_CONST(DATALIST);
|
||||
TIDY_TAG_CONST(DETAILS);
|
||||
TIDY_TAG_CONST(DIALOG);
|
||||
TIDY_TAG_CONST(FIGCAPTION);
|
||||
TIDY_TAG_CONST(FIGURE);
|
||||
TIDY_TAG_CONST(FOOTER);
|
||||
TIDY_TAG_CONST(HEADER);
|
||||
TIDY_TAG_CONST(HGROUP);
|
||||
TIDY_TAG_CONST(MAIN);
|
||||
TIDY_TAG_CONST(MARK);
|
||||
TIDY_TAG_CONST(MENUITEM);
|
||||
TIDY_TAG_CONST(METER);
|
||||
TIDY_TAG_CONST(NAV);
|
||||
TIDY_TAG_CONST(OUTPUT);
|
||||
TIDY_TAG_CONST(PROGRESS);
|
||||
TIDY_TAG_CONST(SECTION);
|
||||
TIDY_TAG_CONST(SOURCE);
|
||||
TIDY_TAG_CONST(SUMMARY);
|
||||
TIDY_TAG_CONST(TEMPLATE);
|
||||
TIDY_TAG_CONST(TIME);
|
||||
TIDY_TAG_CONST(TRACK);
|
||||
TIDY_TAG_CONST(VIDEO);
|
||||
# endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -359,7 +359,10 @@ _external_entity_ref_handler(void *user, const xmlChar *names, int type, const x
|
|||
return;
|
||||
}
|
||||
|
||||
parser->h_external_entity_ref(parser, names, (XML_Char *) "", sys_id, pub_id);
|
||||
if (!parser->h_external_entity_ref(parser, names, (XML_Char *) "", sys_id, pub_id)) {
|
||||
xmlStopParser(parser->parser);
|
||||
parser->parser->errNo = XML_ERROR_EXTERNAL_ENTITY_HANDLING;
|
||||
};
|
||||
}
|
||||
|
||||
static xmlEntityPtr
|
||||
|
|
30
ext/xml/tests/bug71592.phpt
Normal file
30
ext/xml/tests/bug71592.phpt
Normal file
|
@ -0,0 +1,30 @@
|
|||
--TEST--
|
||||
Bug #71592 (External entity processing never fails)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('xml')) die('skip xml extension not available');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$xml = <<<XML
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE p [
|
||||
<!ENTITY pic PUBLIC "image.gif" "http://example.org/image.gif">
|
||||
]>
|
||||
<root>
|
||||
<p>&pic;</p>
|
||||
<p></nop>
|
||||
</root>
|
||||
XML;
|
||||
|
||||
$parser = xml_parser_create_ns('UTF-8');
|
||||
xml_set_external_entity_ref_handler($parser, function () {
|
||||
return false;
|
||||
});
|
||||
xml_parse($parser, $xml);
|
||||
var_dump(xml_get_error_code($parser));
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECT--
|
||||
int(21)
|
||||
===DONE===
|
Loading…
Add table
Add a link
Reference in a new issue