Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions ext/soap/php_encoding.c
Original file line number Diff line number Diff line change
Expand Up @@ -3234,13 +3234,18 @@ static xmlNodePtr to_xml_any(encodeTypePtr type, zval *data, int style, xmlNodeP
zval *el;
encodePtr enc = get_conversion(XSD_ANYXML);
zend_string *name;
zend_ulong idx;

ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(data), name, el) {
ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(data), idx, name, el) {
ret = master_to_xml(enc, el, style, parent);
if (ret && name &&
ret->name != xmlStringTextNoenc) {
if (!ret || ret->name == xmlStringTextNoenc) {
continue;
}
if (name) {
xmlNodeSetName(ret, BAD_CAST(ZSTR_VAL(name)));
}
} else if (ret->type == XML_ELEMENT_NODE && xmlStrEqual(ret->name, BAD_CAST("BOGUS"))) {
soap_error1(E_ERROR, "Encoding: Element at index " ZEND_ULONG_FMT " of 'any' content has no name", idx);
}
} ZEND_HASH_FOREACH_END();
return ret;
}
Expand Down
18 changes: 14 additions & 4 deletions ext/soap/tests/gh25267.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,23 @@ YuanchengJiang
<?php
class C extends SoapClient {
function __doRequest($request, $location, $action, $version, $one_way = false, ?string $uriParserClass = null): string {
echo $request;
preg_match('#<ns1:foo>(.*)</ns1:foo>#', $request, $m);
echo $m[1], PHP_EOL;
return "";
}
}
$c = new C(null, ["location" => "test://", "uri" => "test://"]);
$c->foo(new SoapVar([new SoapVar("y", XSD_STRING), "a" => new SoapVar("x", XSD_STRING)], XSD_ANYXML));

try {
$c->foo(new SoapVar([new SoapVar("y", XSD_STRING), "a" => new SoapVar("x", XSD_STRING)], XSD_ANYXML));
} catch (SoapFault $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}

$c->foo(new SoapVar([new SoapVar("y", XSD_STRING, nodeName: "b"), "a" => new SoapVar("x", XSD_STRING)], XSD_ANYXML));
$c->foo(new SoapVar(["<b>y</b>", "a" => new SoapVar("x", XSD_STRING)], XSD_ANYXML));
?>
--EXPECT--
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="test://" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:foo><BOGUS xsi:type="xsd:string">y</BOGUS><a xsi:type="xsd:string">x</a></ns1:foo></SOAP-ENV:Body></SOAP-ENV:Envelope>
SoapFault: SOAP-ERROR: Encoding: Element at index 0 of 'any' content has no name
<b xsi:type="xsd:string">y</b><a xsi:type="xsd:string">x</a>
<b>y</b><a xsi:type="xsd:string">x</a>
Loading