-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Fix GH-22167: reject out-of-range SOAP schema integers #22178
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
Open
LamentXU123
wants to merge
1
commit into
php:master
Choose a base branch
from
LamentXU123:bug-f-21
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+151
−3
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| --TEST-- | ||
| GH-22167 (Out-of-range XML Schema integer values in SOAP WSDL) | ||
| --EXTENSIONS-- | ||
| soap | ||
| --INI-- | ||
| soap.wsdl_cache_enabled=0 | ||
| --FILE-- | ||
| <?php | ||
| function wsdl_with_schema(string $schema): string { | ||
| return <<<XML | ||
| <?xml version="1.0"?> | ||
| <definitions | ||
| xmlns:xsd="http://www.w3.org/2001/XMLSchema" | ||
| xmlns:tns="http://test-uri/" | ||
| xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" | ||
| xmlns="http://schemas.xmlsoap.org/wsdl/" | ||
| targetNamespace="http://test-uri/"> | ||
| <types> | ||
| <xsd:schema targetNamespace="http://test-uri/"> | ||
| $schema | ||
| </xsd:schema> | ||
| </types> | ||
| <message name="m"><part name="p" type="tns:T"/></message> | ||
| <portType name="p"><operation name="op"><input message="tns:m"/></operation></portType> | ||
| <binding name="b" type="tns:p"> | ||
| <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> | ||
| <operation name="op"> | ||
| <soap:operation soapAction="#op"/> | ||
| <input> | ||
| <soap:body use="encoded" | ||
| namespace="http://test-uri/" | ||
| encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> | ||
| </input> | ||
| </operation> | ||
| </binding> | ||
| <service name="s"><port name="p" binding="tns:b"><soap:address location="test://"/></port></service> | ||
| </definitions> | ||
| XML; | ||
| } | ||
|
|
||
| function occurrence_schema(string $attribute, string $value = "2147483648"): string { | ||
| return <<<XML | ||
| <xsd:complexType name="T"> | ||
| <xsd:sequence> | ||
| <xsd:element name="x" type="xsd:string" $attribute="$value"/> | ||
| </xsd:sequence> | ||
| </xsd:complexType> | ||
| XML; | ||
| } | ||
|
|
||
| function restriction_schema(string $facet, string $value = "2147483648"): string { | ||
| return <<<XML | ||
| <xsd:simpleType name="T"> | ||
| <xsd:restriction base="xsd:int"> | ||
| <xsd:$facet value="$value"/> | ||
| </xsd:restriction> | ||
| </xsd:simpleType> | ||
| XML; | ||
| } | ||
|
|
||
| $cases = [ | ||
| "minOccurs" => occurrence_schema("minOccurs"), | ||
| "maxOccurs" => occurrence_schema("maxOccurs"), | ||
| "minExclusive" => restriction_schema("minExclusive"), | ||
| "minInclusive" => restriction_schema("minInclusive"), | ||
| "maxExclusive" => restriction_schema("maxExclusive"), | ||
| "maxInclusive" => restriction_schema("maxInclusive"), | ||
| "totalDigits" => restriction_schema("totalDigits"), | ||
| "fractionDigits" => restriction_schema("fractionDigits"), | ||
| "length" => restriction_schema("length"), | ||
| "minLength" => restriction_schema("minLength"), | ||
| "maxLength" => restriction_schema("maxLength"), | ||
| ]; | ||
|
|
||
| $numeric_string_cases = [ | ||
| "leading whitespace numeric-string" => " 2147483648", | ||
| "leading plus numeric-string" => "+2147483648", | ||
| "leading zero numeric-string" => "00000000002147483648", | ||
| "leading numeric-string with trailing data" => "2147483648abc", | ||
| "decimal numeric-string" => "2147483648.0", | ||
| "exponent numeric-string" => "2147483648e0", | ||
| ]; | ||
|
|
||
| foreach ($numeric_string_cases as $name => $value) { | ||
| $cases[$name] = occurrence_schema("maxOccurs", $value); | ||
| } | ||
|
|
||
| $cases["fractional numeric-string within int range"] = occurrence_schema("maxOccurs", "3.141"); | ||
|
|
||
| foreach ($cases as $name => $schema) { | ||
| $file = tempnam(sys_get_temp_dir(), "wsdl"); | ||
| file_put_contents($file, wsdl_with_schema($schema)); | ||
|
|
||
| try { | ||
| new SoapClient($file, ["cache_wsdl" => WSDL_CACHE_NONE]); | ||
| echo "$name: parsed\n"; | ||
| } catch (SoapFault $e) { | ||
| echo "$name: {$e->getMessage()}\n"; | ||
| } finally { | ||
| unlink($file); | ||
| } | ||
| } | ||
| ?> | ||
| --EXPECT-- | ||
| minOccurs: SOAP-ERROR: Parsing Schema: minOccurs value is out of range | ||
| maxOccurs: SOAP-ERROR: Parsing Schema: maxOccurs value is out of range | ||
| minExclusive: SOAP-ERROR: Parsing Schema: minExclusive value is out of range | ||
| minInclusive: SOAP-ERROR: Parsing Schema: minInclusive value is out of range | ||
| maxExclusive: SOAP-ERROR: Parsing Schema: maxExclusive value is out of range | ||
| maxInclusive: SOAP-ERROR: Parsing Schema: maxInclusive value is out of range | ||
| totalDigits: SOAP-ERROR: Parsing Schema: totalDigits value is out of range | ||
| fractionDigits: SOAP-ERROR: Parsing Schema: fractionDigits value is out of range | ||
| length: SOAP-ERROR: Parsing Schema: length value is out of range | ||
| minLength: SOAP-ERROR: Parsing Schema: minLength value is out of range | ||
| maxLength: SOAP-ERROR: Parsing Schema: maxLength value is out of range | ||
| leading whitespace numeric-string: SOAP-ERROR: Parsing Schema: maxOccurs value is out of range | ||
| leading plus numeric-string: SOAP-ERROR: Parsing Schema: maxOccurs value is out of range | ||
| leading zero numeric-string: SOAP-ERROR: Parsing Schema: maxOccurs value is out of range | ||
| leading numeric-string with trailing data: SOAP-ERROR: Parsing Schema: maxOccurs value is out of range | ||
| decimal numeric-string: SOAP-ERROR: Parsing Schema: maxOccurs value is out of range | ||
| exponent numeric-string: SOAP-ERROR: Parsing Schema: maxOccurs value is out of range | ||
| fractional numeric-string within int range: parsed | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about adding as well ?