Skip to content

Commit

Permalink
Merge branch 'master' into preload
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
dstogov committed Oct 29, 2018
2 parents d7fbb4d + 359f19e commit 386c9d3
Show file tree
Hide file tree
Showing 7 changed files with 139 additions and 41 deletions.
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 30 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -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
========================================
Expand Down
1 change: 1 addition & 0 deletions ext/opcache/Optimizer/zend_func_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
81 changes: 41 additions & 40 deletions ext/standard/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/* 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) {
} else if (f < 0) {
/* if "from" position is negative, count start position from the end
* of the string
*/
if ((size_t)-f > ZSTR_LEN(str)) {
f = 0;
} else {
f = (zend_long)ZSTR_LEN(str) + f;
}
}

/* 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 (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) {
if ((size_t)(-l) > ZSTR_LEN(str)) {
RETURN_FALSE;
} else {
l = 0;
}
} else {
l = (zend_long)ZSTR_LEN(str) - f + l;
}
} 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) {
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;
}
} else if ((size_t)l > ZSTR_LEN(str) - (size_t)f) {
goto truncate_len;
}
}

if (f > (zend_long)ZSTR_LEN(str)) {
RETURN_FALSE;
}

if ((size_t)l > ZSTR_LEN(str) - (size_t)f) {
l = ZSTR_LEN(str) - f;
} else {
truncate_len:
l = (zend_long)ZSTR_LEN(str) - f;
}

if (l == 0) {
Expand Down
30 changes: 30 additions & 0 deletions ext/tidy/tidy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion ext/xml/compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 30 additions & 0 deletions ext/xml/tests/bug71592.phpt
Original file line number Diff line number Diff line change
@@ -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===

0 comments on commit 386c9d3

Please sign in to comment.