|
| 1 | +--TEST-- |
| 2 | +GH-22167 (Out-of-range XML Schema integer values in SOAP WSDL) |
| 3 | +--EXTENSIONS-- |
| 4 | +soap |
| 5 | +--INI-- |
| 6 | +soap.wsdl_cache_enabled=0 |
| 7 | +--FILE-- |
| 8 | +<?php |
| 9 | +function wsdl_with_schema(string $schema): string { |
| 10 | + return <<<XML |
| 11 | +<?xml version="1.0"?> |
| 12 | +<definitions |
| 13 | + xmlns:xsd="http://www.w3.org/2001/XMLSchema" |
| 14 | + xmlns:tns="http://test-uri/" |
| 15 | + xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" |
| 16 | + xmlns="http://schemas.xmlsoap.org/wsdl/" |
| 17 | + targetNamespace="http://test-uri/"> |
| 18 | + <types> |
| 19 | + <xsd:schema targetNamespace="http://test-uri/"> |
| 20 | + $schema |
| 21 | + </xsd:schema> |
| 22 | + </types> |
| 23 | + <message name="m"><part name="p" type="tns:T"/></message> |
| 24 | + <portType name="p"><operation name="op"><input message="tns:m"/></operation></portType> |
| 25 | + <binding name="b" type="tns:p"> |
| 26 | + <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> |
| 27 | + <operation name="op"> |
| 28 | + <soap:operation soapAction="#op"/> |
| 29 | + <input> |
| 30 | + <soap:body use="encoded" |
| 31 | + namespace="http://test-uri/" |
| 32 | + encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> |
| 33 | + </input> |
| 34 | + </operation> |
| 35 | + </binding> |
| 36 | + <service name="s"><port name="p" binding="tns:b"><soap:address location="test://"/></port></service> |
| 37 | +</definitions> |
| 38 | +XML; |
| 39 | +} |
| 40 | + |
| 41 | +function occurrence_schema(string $attribute, string $value = "2147483648"): string { |
| 42 | + return <<<XML |
| 43 | +<xsd:complexType name="T"> |
| 44 | + <xsd:sequence> |
| 45 | + <xsd:element name="x" type="xsd:string" $attribute="$value"/> |
| 46 | + </xsd:sequence> |
| 47 | +</xsd:complexType> |
| 48 | +XML; |
| 49 | +} |
| 50 | + |
| 51 | +function restriction_schema(string $facet, string $value = "2147483648"): string { |
| 52 | + return <<<XML |
| 53 | +<xsd:simpleType name="T"> |
| 54 | + <xsd:restriction base="xsd:int"> |
| 55 | + <xsd:$facet value="$value"/> |
| 56 | + </xsd:restriction> |
| 57 | +</xsd:simpleType> |
| 58 | +XML; |
| 59 | +} |
| 60 | + |
| 61 | +$cases = [ |
| 62 | + "minOccurs" => occurrence_schema("minOccurs"), |
| 63 | + "maxOccurs" => occurrence_schema("maxOccurs"), |
| 64 | + "negative minOccurs" => occurrence_schema("minOccurs", "-1"), |
| 65 | + "negative maxOccurs" => occurrence_schema("maxOccurs", "-1"), |
| 66 | + "minExclusive" => restriction_schema("minExclusive"), |
| 67 | + "minInclusive" => restriction_schema("minInclusive"), |
| 68 | + "maxExclusive" => restriction_schema("maxExclusive"), |
| 69 | + "maxInclusive" => restriction_schema("maxInclusive"), |
| 70 | + "totalDigits" => restriction_schema("totalDigits"), |
| 71 | + "fractionDigits" => restriction_schema("fractionDigits"), |
| 72 | + "length" => restriction_schema("length"), |
| 73 | + "minLength" => restriction_schema("minLength"), |
| 74 | + "maxLength" => restriction_schema("maxLength"), |
| 75 | +]; |
| 76 | + |
| 77 | +$numeric_string_cases = [ |
| 78 | + "leading whitespace numeric-string" => " 2147483648", |
| 79 | + "leading plus numeric-string" => "+2147483648", |
| 80 | + "leading zero numeric-string" => "00000000002147483648", |
| 81 | + "leading numeric-string with trailing data" => "2147483648abc", |
| 82 | + "negative out-of-range numeric-string" => "-2147483649", |
| 83 | + "decimal numeric-string" => "2147483648.0", |
| 84 | + "exponent numeric-string" => "2147483648e0", |
| 85 | +]; |
| 86 | + |
| 87 | +foreach ($numeric_string_cases as $name => $value) { |
| 88 | + $cases[$name] = occurrence_schema("maxOccurs", $value); |
| 89 | +} |
| 90 | + |
| 91 | +$cases["fractional numeric-string within int range"] = occurrence_schema("maxOccurs", "3.141"); |
| 92 | + |
| 93 | +foreach ($cases as $name => $schema) { |
| 94 | + $file = tempnam(sys_get_temp_dir(), "wsdl"); |
| 95 | + file_put_contents($file, wsdl_with_schema($schema)); |
| 96 | + |
| 97 | + try { |
| 98 | + new SoapClient($file, ["cache_wsdl" => WSDL_CACHE_NONE]); |
| 99 | + echo "$name: parsed\n"; |
| 100 | + } catch (SoapFault $e) { |
| 101 | + echo "$name: {$e->getMessage()}\n"; |
| 102 | + } finally { |
| 103 | + unlink($file); |
| 104 | + } |
| 105 | +} |
| 106 | +?> |
| 107 | +--EXPECT-- |
| 108 | +minOccurs: SOAP-ERROR: Parsing Schema: minOccurs value is out of range |
| 109 | +maxOccurs: SOAP-ERROR: Parsing Schema: maxOccurs value is out of range |
| 110 | +negative minOccurs: SOAP-ERROR: Parsing Schema: minOccurs value is out of range |
| 111 | +negative maxOccurs: SOAP-ERROR: Parsing Schema: maxOccurs value is out of range |
| 112 | +minExclusive: SOAP-ERROR: Parsing Schema: minExclusive value is out of range |
| 113 | +minInclusive: SOAP-ERROR: Parsing Schema: minInclusive value is out of range |
| 114 | +maxExclusive: SOAP-ERROR: Parsing Schema: maxExclusive value is out of range |
| 115 | +maxInclusive: SOAP-ERROR: Parsing Schema: maxInclusive value is out of range |
| 116 | +totalDigits: SOAP-ERROR: Parsing Schema: totalDigits value is out of range |
| 117 | +fractionDigits: SOAP-ERROR: Parsing Schema: fractionDigits value is out of range |
| 118 | +length: SOAP-ERROR: Parsing Schema: length value is out of range |
| 119 | +minLength: SOAP-ERROR: Parsing Schema: minLength value is out of range |
| 120 | +maxLength: SOAP-ERROR: Parsing Schema: maxLength value is out of range |
| 121 | +leading whitespace numeric-string: SOAP-ERROR: Parsing Schema: maxOccurs value is out of range |
| 122 | +leading plus numeric-string: SOAP-ERROR: Parsing Schema: maxOccurs value is out of range |
| 123 | +leading zero numeric-string: SOAP-ERROR: Parsing Schema: maxOccurs value is out of range |
| 124 | +leading numeric-string with trailing data: SOAP-ERROR: Parsing Schema: maxOccurs value is out of range |
| 125 | +negative out-of-range numeric-string: SOAP-ERROR: Parsing Schema: maxOccurs value is out of range |
| 126 | +decimal numeric-string: SOAP-ERROR: Parsing Schema: maxOccurs value is out of range |
| 127 | +exponent numeric-string: SOAP-ERROR: Parsing Schema: maxOccurs value is out of range |
| 128 | +fractional numeric-string within int range: parsed |
0 commit comments