Skip to content

Commit ca40da4

Browse files
committed
Add trampoline test for generic XMLParser handler
1 parent 4ec0dab commit ca40da4

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
--TEST--
2+
Test XMLParser generic handlers as trampoline callback
3+
--EXTENSIONS--
4+
xml
5+
--FILE--
6+
<?php
7+
class TrampolineTest {
8+
public function __call(string $name, array $arguments) {
9+
echo 'Trampoline for ', $name, PHP_EOL;
10+
echo 'Target: ', $arguments[1], PHP_EOL;
11+
echo 'Data: ', $arguments[2], PHP_EOL;
12+
}
13+
}
14+
15+
$o = new TrampolineTest();
16+
$callback = [$o, 'pi_handler'];
17+
18+
$xml = <<<HERE
19+
<?xml version="1.0" encoding="ISO-8859-1"?>
20+
<?xml-stylesheet href="default.xsl" type="text/xml"?>
21+
HERE;
22+
23+
/* Use xml_set_processing_instruction_handler() for generic implementation */
24+
$parser = xml_parser_create();
25+
xml_set_processing_instruction_handler($parser, $callback);
26+
xml_parse($parser, $xml, true);
27+
xml_parser_free($parser);
28+
29+
?>
30+
--EXPECT--
31+
Trampoline for pi_handler
32+
Target: xml-stylesheet
33+
Data: href="default.xsl" type="text/xml"

ext/xml/xml.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1203,7 +1203,7 @@ static void php_xml_set_handler_parse_callable(
12031203
/* Free handler, so just return and a uninitialized FCC communicates this */
12041204
return;
12051205
}
1206-
if (!ZEND_FCC_INITIALIZED(handler_fcc)) { // TODO: cover this with a test, this is never executed right now
1206+
if (!ZEND_FCC_INITIALIZED(handler_fcc)) {
12071207
zend_is_callable_ex(&handler_fci.function_name, NULL, IS_CALLABLE_SUPPRESS_DEPRECATIONS, NULL, &handler_fcc, NULL);
12081208
/* Call trampoline has been cleared by zpp. Refetch it, because we want to deal
12091209
* with it ourselves. It is important that it is not refetched on every call,

0 commit comments

Comments
 (0)