Skip to content

ext/soap: Fix SOAP classmap validation for integer keys#22884

Open
LamentXU123 wants to merge 1 commit into
php:masterfrom
LamentXU123:soap-todo
Open

ext/soap: Fix SOAP classmap validation for integer keys#22884
LamentXU123 wants to merge 1 commit into
php:masterfrom
LamentXU123:soap-todo

Conversation

@LamentXU123

Copy link
Copy Markdown
Member

Previously, SOAP only rejected packed arrays, which still allowed sparse integer-keyed arrays and mixed string integer-keyed arrays to be accepted.

Since classmap is expected to be an associative mapping, arrays containing integer keys are now rejected consistently.

@devnexen

Copy link
Copy Markdown
Member

could you add the following test please ?

--TEST--
SoapClient must not read a packed "classmap" array as a hash
--EXTENSIONS--
soap
--FILE--
<?php

class LocalClient extends SoapClient
{
    public function __doRequest(string $request, string $location, string $action, int $version, bool $oneWay = false, ?string $uriParserClass = null): ?string
    {
        echo $request, PHP_EOL;

        return <<<XML
        <?xml version="1.0" encoding="UTF-8"?>
        <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
          <SOAP-ENV:Body><ns1:doItResponse xmlns:ns1="urn:test"/></SOAP-ENV:Body>
        </SOAP-ENV:Envelope>
        XML;
    }
}

$client = new LocalClient(null, [
    'location' => 'http://example.com/',
    'uri' => 'urn:test',
    'classmap' => ['SomeType' => 'stdClass'],
]);

$property = new ReflectionProperty(SoapClient::class, '_classmap');
$property->setValue($client, ['stdClass', 'stdClass']);

$client->__soapCall('doIt', [new stdClass()]);

echo 'done', PHP_EOL;

?>
--EXPECTF--
%A
done

Co-Authored-By: David CARLIER <devnexen@gmail.com>
@LamentXU123

Copy link
Copy Markdown
Member Author

This is indeed a bug when SoapClient::_classmap can be reflected as a packed array :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants