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

[email protected] (LamentXU123)
Newsgroups php.git-pulls
Message-ID <[email protected]>
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"
```
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.