xref: /php-src/ext/soap/tests/bugs/bug68996.phpt (revision 5048a065)
1--TEST--
2Bug #68996 (Invalid free of CG(interned_empty_string))
3--EXTENSIONS--
4soap
5--SKIPIF--
6<?php
7if (getenv("USE_ZEND_ALLOC") !== "0")
8    print "skip Need Zend MM disabled";
9?>
10--FILE--
11<?php
12$s = new SoapServer(NULL, [
13    'uri' => 'http://foo',
14]);
15
16function foo() {
17  return new SoapFault("\xfc\x63", "some msg");
18}
19$s->addFunction("foo");
20
21function handleFormatted($s, $input) {
22  ob_start();
23  $s->handle($input);
24  $response = ob_get_clean();
25
26  // libxml2 2.13 has different formatting behaviour: it outputs <faultcode/> instead of <faultcode></faultcode>
27  // this normalizes the output to <faultcode/>
28  $response = str_replace('<faultcode></faultcode>', '<faultcode/>', $response);
29  $response = str_replace('<env:Value></env:Value>', '<env:Value/>', $response);
30  echo $response;
31}
32
33// soap 1.1
34$HTTP_RAW_POST_DATA = <<<EOF
35<?xml version="1.0" encoding="UTF-8"?>
36<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
37  <SOAP-ENV:Body>
38    <SOAP-ENV:foo />
39  </SOAP-ENV:Body>
40</SOAP-ENV:Envelope>
41EOF;
42handleFormatted($s, $HTTP_RAW_POST_DATA);
43
44// soap 1.2
45$HTTP_RAW_POST_DATA = <<<EOF
46<?xml version="1.0" encoding="UTF-8"?>
47<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
48  <env:Body>
49    <env:foo />
50  </env:Body>
51</env:Envelope>
52EOF;
53handleFormatted($s, $HTTP_RAW_POST_DATA);
54?>
55--EXPECT--
56<?xml version="1.0" encoding="UTF-8"?>
57<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode/><faultstring>some msg</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
58<?xml version="1.0" encoding="UTF-8"?>
59<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"><env:Body><env:Fault><env:Code><env:Value/></env:Code><env:Reason><env:Text>some msg</env:Text></env:Reason></env:Fault></env:Body></env:Envelope>
60