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
6 changes: 5 additions & 1 deletion ext/soap/soap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1394,7 +1394,7 @@ PHP_METHOD(SoapServer, handle)
}
}

if ((soap_action_z = zend_hash_str_find(Z_ARRVAL_P(server_vars), ZEND_STRL("HTTP_SOAPACTION"))) != NULL && Z_TYPE_P(soap_action_z) == IS_STRING) {
if ((soap_action_z = zend_hash_str_find(Z_ARRVAL_P(server_vars), ZEND_STRL("HTTP_SOAPACTION"))) != NULL && Z_TYPE_P(soap_action_z) == IS_STRING && Z_STRLEN_P(soap_action_z) > 0) {
soap_action = Z_STRVAL_P(soap_action_z);
}
}
Expand Down Expand Up @@ -3178,6 +3178,10 @@ static sdlFunctionPtr find_function_using_soap_action(const sdl *sdl, const char
soap_action_length -= 2;
}

if (UNEXPECTED(soap_action_length == 0)) {
return NULL;
}

/* TODO: This may depend on a particular target namespace, in which case this won't find a match when multiple different
* target namespaces are used until #45282 is resolved. */
sdlFunctionPtr function;
Expand Down
45 changes: 45 additions & 0 deletions ext/soap/tests/bugs/gh22285.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
--TEST--
GH-22285 (SoapServer dispatches to the first function when the SOAPAction header is empty)
--CREDITS--
Jarkko Hyvärinen
--EXTENSIONS--
soap
--INI--
soap.wsdl_cache_enabled=0
--SKIPIF--
<?php
if (php_sapi_name()=='cli') echo 'skip';
?>
--POST--
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="urn:TestService">
<SOAP-ENV:Body>
<ns1:goodbyeIn>
<name>World</name>
</ns1:goodbyeIn>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
--FILE--
<?php
class TestWS {
public function hello($params) {
return ['message' => 'Hello ' . $params->name];
}
public function goodbye($params) {
return ['message' => 'Goodbye ' . $params->name];
}
}

$server = new SoapServer(__DIR__ . '/gh22285.wsdl', [
'cache_wsdl' => WSDL_CACHE_NONE,
'encoding' => 'UTF-8',
'soap_version' => SOAP_1_1,
]);
$server->setClass('TestWS');
$_SERVER['HTTP_SOAPACTION'] = '""';
$server->handle();
?>
--EXPECTF--
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:TestService"><SOAP-ENV:Body><ns1:goodbyeOut><message>Goodbye World</message></ns1:goodbyeOut></SOAP-ENV:Body></SOAP-ENV:Envelope>
96 changes: 96 additions & 0 deletions ext/soap/tests/bugs/gh22285.wsdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions
name="TestService"
targetNamespace="urn:TestService"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tns="urn:TestService"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">

<wsdl:types>
<xsd:schema targetNamespace="urn:TestService">
<xsd:element name="helloIn">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="name" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="helloOut">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="message" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="goodbyeIn">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="name" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="goodbyeOut">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="message" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>

<wsdl:message name="helloRequest">
<wsdl:part element="tns:helloIn" name="helloIn" />
</wsdl:message>
<wsdl:message name="helloResponse">
<wsdl:part element="tns:helloOut" name="helloOut" />
</wsdl:message>
<wsdl:message name="goodbyeRequest">
<wsdl:part element="tns:goodbyeIn" name="goodbyeIn" />
</wsdl:message>
<wsdl:message name="goodbyeResponse">
<wsdl:part element="tns:goodbyeOut" name="goodbyeOut" />
</wsdl:message>

<wsdl:portType name="TestServicePortType">
<wsdl:operation name="hello">
<wsdl:input message="tns:helloRequest" name="helloRequest" />
<wsdl:output message="tns:helloResponse" name="helloResponse" />
</wsdl:operation>
<wsdl:operation name="goodbye">
<wsdl:input message="tns:goodbyeRequest" name="goodbyeRequest" />
<wsdl:output message="tns:goodbyeResponse" name="goodbyeResponse" />
</wsdl:operation>
</wsdl:portType>

<wsdl:binding name="TestServiceBinding" type="tns:TestServicePortType">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="hello">
<wsdlsoap:operation soapAction="" />
<wsdl:input name="helloRequest">
<wsdlsoap:body use="literal" />
</wsdl:input>
<wsdl:output name="helloResponse">
<wsdlsoap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="goodbye">
<wsdlsoap:operation soapAction="" />
<wsdl:input name="goodbyeRequest">
<wsdlsoap:body use="literal" />
</wsdl:input>
<wsdl:output name="goodbyeResponse">
<wsdlsoap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>

<wsdl:service name="TestService">
<wsdl:port name="TestServicePort" binding="tns:TestServiceBinding">
<wsdlsoap:address location="http://localhost/server.php" />
</wsdl:port>
</wsdl:service>

</wsdl:definitions>
Loading