[php-src] PR #22698: ext/soap: Fix SOAP xsd:hexBinary odd-length decoding

From: Date: Sat, 11 Jul 2026 17:19:24 +0000
Subject: [php-src] PR #22698: ext/soap: Fix SOAP xsd:hexBinary odd-length decoding
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-36977@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/22698 Author: LamentXU123 xsd:hexBinary values must contain an even number of hexadecimal digits. However, previously we allocated strlen(content) / 2 bytes and decoded only complete byte pairs. As a result, an odd-length value such as ABC was accepted as ab (what...?), *silently* ignoring the trailing nibble. Lets reject odd-length xsd:hexBinary values instead and throw an Error here which makes better sense. The error message is copied from other decoding errors. (I think in the future, we can make the decoding error message more useful, in bulk.) ```php <?php class TestSoapClient extends SoapClient { public function __doRequest( $request, $location, $action, $version, $one_way = false, ?string $uriParserClass = null ): string { return <<<'XML' <?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <SOAP-ENV:Body> <ns1:testResponse xmlns:ns1="urn:test"> <return xsi:type="xsd:hexBinary">ABC</return> </ns1:testResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope> XML; } } $client = new TestSoapClient(null, [ 'location' => 'test://', 'uri' => 'urn:test', 'exceptions' => true, ]); var_dump(bin2hex($client->test())); ``` ``` string(2) "ab" ```

« previous php.git-pulls (#36977) next »