Skip to content

SoapClient can't parse WSDL file correctly #8538

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
TheOneThingSpecial opened this issue May 12, 2022 · 6 comments
Closed

SoapClient can't parse WSDL file correctly #8538

TheOneThingSpecial opened this issue May 12, 2022 · 6 comments

Comments

@TheOneThingSpecial
Copy link

TheOneThingSpecial commented May 12, 2022

Description

The following code:

<?php
function testsoap()
{
    try {
        $client = new SoapClient('tmp.txt'); 
        $res = $client->__getFunctions();
        var_dump($res);
    } catch (Exception $e) {
        var_dump($e->getMessage());
    }
}

testsoap();

tmp.txt:
tmp.txt

Resulted in this output:
image

But I expected this output instead:
image

Test:
When I modify the source file ext/soap/php_sdl.c and add debugging information, as shown below:
image
I got the result as below:
image
So I think there might be a problem with this line
ctype = strrchr((char*)type->children->content,':');

PHP Version

PHP 7.3.24

Operating System

Centos 6.10

@damianwadley
Copy link
Member

<wsdl:portType name="http://wssmcommupper/">

This is quite clearly incorrect.

@TheOneThingSpecial
Copy link
Author

I can correctly parse the WSDL file with soapUI tool, so I think PHP may not handle it correctly!
image

@damianwadley
Copy link
Member

I can correctly parse the WSDL file with soapUI tool, so I think PHP may not handle it correctly!

The WSDL itself is not correct because the name of that type is not valid. If some other tool doesn't care then that's nice.

But I don't have the desire to try to explain that any more.

@cmb69
Copy link
Member

cmb69 commented May 12, 2022

Please don't post screenshots if the text can easily copy&pasted into the ticket.

@cmb69
Copy link
Member

cmb69 commented May 12, 2022

<wsdl:portType name="http://wssmcommupper/">

This is quite clearly incorrect.

Right, it needs to be an nmtoken. However, I think that <wsdl:portType name="http:wssmcommupper"> would be correct (well, let's say allowed), but that results in the same behavior.

So I think there might be a problem with this line
ctype = strrchr((char*)type->children->content,':');

I concur. Just looking for the rightmost colon doesn't look right. From what I can tell, this line is supposed to strip the namespace prefix, which is not allowed to contain any colons, so using strchr() instead of strrchr() appears to be the correct solution.

@cmb69
Copy link
Member

cmb69 commented May 12, 2022

PHP 7.3.24

PHP-7.3 is no longer actively supported; that doesn't matter wrt. this ticket, since the relevant code hasn't changed, but you want to update to any of the supported versions anyway.

cmb69 added a commit to cmb69/php-src that referenced this issue May 12, 2022
When stripping the namespace prefix, we can assume that this does not
contain any colons, while the rest of the name may contain colons.
Hence we must not use `strrchr()` but rather `strchr()` instead.
@cmb69 cmb69 self-assigned this May 12, 2022
@cmb69 cmb69 linked a pull request May 12, 2022 that will close this issue
cmb69 added a commit that referenced this issue May 23, 2022
* PHP-8.0:
  Fix GH-8538: SoapClient may strip parts of nmtokens
@cmb69 cmb69 closed this as completed in 2a13304 May 23, 2022
cmb69 added a commit that referenced this issue May 23, 2022
* PHP-8.1:
  Fix GH-8538: SoapClient may strip parts of nmtokens
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants
@cmb69 @damianwadley @TheOneThingSpecial and others