@@ -40,11 +40,11 @@ bool parse_packet_soap(zval *this_ptr, char *buffer, int buffer_size, sdlFunctio
4040 response = soap_xmlParseMemory (buffer , buffer_size );
4141
4242 if (!response ) {
43- add_soap_fault (this_ptr , "Client" , "looks like we got no XML document" , NULL , NULL );
43+ add_soap_fault (this_ptr , "Client" , "looks like we got no XML document" , NULL , NULL , SOAP_GLOBAL ( lang_en ) );
4444 return false;
4545 }
4646 if (xmlGetIntSubset (response ) != NULL ) {
47- add_soap_fault (this_ptr , "Client" , "DTD are not supported by SOAP" , NULL , NULL );
47+ add_soap_fault (this_ptr , "Client" , "DTD are not supported by SOAP" , NULL , NULL , SOAP_GLOBAL ( lang_en ) );
4848 xmlFreeDoc (response );
4949 return false;
5050 }
@@ -63,32 +63,32 @@ bool parse_packet_soap(zval *this_ptr, char *buffer, int buffer_size, sdlFunctio
6363 envelope_ns = SOAP_1_2_ENV_NAMESPACE ;
6464 soap_version = SOAP_1_2 ;
6565 } else {
66- add_soap_fault (this_ptr , "VersionMismatch" , "Wrong Version" , NULL , NULL );
66+ add_soap_fault (this_ptr , "VersionMismatch" , "Wrong Version" , NULL , NULL , SOAP_GLOBAL ( lang_en ) );
6767 xmlFreeDoc (response );
6868 return false;
6969 }
7070 }
7171 trav = trav -> next ;
7272 }
7373 if (env == NULL ) {
74- add_soap_fault (this_ptr , "Client" , "looks like we got XML without \"Envelope\" element" , NULL , NULL );
74+ add_soap_fault (this_ptr , "Client" , "looks like we got XML without \"Envelope\" element" , NULL , NULL , SOAP_GLOBAL ( lang_en ) );
7575 xmlFreeDoc (response );
7676 return false;
7777 }
7878
7979 attr = env -> properties ;
8080 while (attr != NULL ) {
8181 if (attr -> ns == NULL ) {
82- add_soap_fault (this_ptr , "Client" , "A SOAP Envelope element cannot have non Namespace qualified attributes" , NULL , NULL );
82+ add_soap_fault (this_ptr , "Client" , "A SOAP Envelope element cannot have non Namespace qualified attributes" , NULL , NULL , SOAP_GLOBAL ( lang_en ) );
8383 xmlFreeDoc (response );
8484 return false;
8585 } else if (attr_is_equal_ex (attr ,"encodingStyle" ,SOAP_1_2_ENV_NAMESPACE )) {
8686 if (soap_version == SOAP_1_2 ) {
87- add_soap_fault (this_ptr , "Client" , "encodingStyle cannot be specified on the Envelope" , NULL , NULL );
87+ add_soap_fault (this_ptr , "Client" , "encodingStyle cannot be specified on the Envelope" , NULL , NULL , SOAP_GLOBAL ( lang_en ) );
8888 xmlFreeDoc (response );
8989 return false;
9090 } else if (strcmp ((char * )attr -> children -> content , SOAP_1_1_ENC_NAMESPACE ) != 0 ) {
91- add_soap_fault (this_ptr , "Client" , "Unknown data encoding style" , NULL , NULL );
91+ add_soap_fault (this_ptr , "Client" , "Unknown data encoding style" , NULL , NULL , SOAP_GLOBAL ( lang_en ) );
9292 xmlFreeDoc (response );
9393 return false;
9494 }
@@ -120,33 +120,33 @@ bool parse_packet_soap(zval *this_ptr, char *buffer, int buffer_size, sdlFunctio
120120 trav = trav -> next ;
121121 }
122122 if (body == NULL ) {
123- add_soap_fault (this_ptr , "Client" , "Body must be present in a SOAP envelope" , NULL , NULL );
123+ add_soap_fault (this_ptr , "Client" , "Body must be present in a SOAP envelope" , NULL , NULL , SOAP_GLOBAL ( lang_en ) );
124124 xmlFreeDoc (response );
125125 return false;
126126 }
127127 attr = body -> properties ;
128128 while (attr != NULL ) {
129129 if (attr -> ns == NULL ) {
130130 if (soap_version == SOAP_1_2 ) {
131- add_soap_fault (this_ptr , "Client" , "A SOAP Body element cannot have non Namespace qualified attributes" , NULL , NULL );
131+ add_soap_fault (this_ptr , "Client" , "A SOAP Body element cannot have non Namespace qualified attributes" , NULL , NULL , SOAP_GLOBAL ( lang_en ) );
132132 xmlFreeDoc (response );
133133 return false;
134134 }
135135 } else if (attr_is_equal_ex (attr ,"encodingStyle" ,SOAP_1_2_ENV_NAMESPACE )) {
136136 if (soap_version == SOAP_1_2 ) {
137- add_soap_fault (this_ptr , "Client" , "encodingStyle cannot be specified on the Body" , NULL , NULL );
137+ add_soap_fault (this_ptr , "Client" , "encodingStyle cannot be specified on the Body" , NULL , NULL , SOAP_GLOBAL ( lang_en ) );
138138 xmlFreeDoc (response );
139139 return false;
140140 } else if (strcmp ((char * )attr -> children -> content , SOAP_1_1_ENC_NAMESPACE ) != 0 ) {
141- add_soap_fault (this_ptr , "Client" , "Unknown data encoding style" , NULL , NULL );
141+ add_soap_fault (this_ptr , "Client" , "Unknown data encoding style" , NULL , NULL , SOAP_GLOBAL ( lang_en ) );
142142 xmlFreeDoc (response );
143143 return false;
144144 }
145145 }
146146 attr = attr -> next ;
147147 }
148148 if (trav != NULL && soap_version == SOAP_1_2 ) {
149- add_soap_fault (this_ptr , "Client" , "A SOAP 1.2 envelope can contain only Header and Body" , NULL , NULL );
149+ add_soap_fault (this_ptr , "Client" , "A SOAP 1.2 envelope can contain only Header and Body" , NULL , NULL , SOAP_GLOBAL ( lang_en ) );
150150 xmlFreeDoc (response );
151151 return false;
152152 }
@@ -155,16 +155,16 @@ bool parse_packet_soap(zval *this_ptr, char *buffer, int buffer_size, sdlFunctio
155155 attr = head -> properties ;
156156 while (attr != NULL ) {
157157 if (attr -> ns == NULL ) {
158- add_soap_fault (this_ptr , "Client" , "A SOAP Header element cannot have non Namespace qualified attributes" , NULL , NULL );
158+ add_soap_fault (this_ptr , "Client" , "A SOAP Header element cannot have non Namespace qualified attributes" , NULL , NULL , SOAP_GLOBAL ( lang_en ) );
159159 xmlFreeDoc (response );
160160 return false;
161161 } else if (attr_is_equal_ex (attr ,"encodingStyle" ,SOAP_1_2_ENV_NAMESPACE )) {
162162 if (soap_version == SOAP_1_2 ) {
163- add_soap_fault (this_ptr , "Client" , "encodingStyle cannot be specified on the Header" , NULL , NULL );
163+ add_soap_fault (this_ptr , "Client" , "encodingStyle cannot be specified on the Header" , NULL , NULL , SOAP_GLOBAL ( lang_en ) );
164164 xmlFreeDoc (response );
165165 return false;
166166 } else if (strcmp ((char * )attr -> children -> content , SOAP_1_1_ENC_NAMESPACE ) != 0 ) {
167- add_soap_fault (this_ptr , "Client" , "Unknown data encoding style" , NULL , NULL );
167+ add_soap_fault (this_ptr , "Client" , "Unknown data encoding style" , NULL , NULL , SOAP_GLOBAL ( lang_en ) );
168168 xmlFreeDoc (response );
169169 return false;
170170 }
@@ -177,6 +177,7 @@ bool parse_packet_soap(zval *this_ptr, char *buffer, int buffer_size, sdlFunctio
177177 fault = get_node_ex (body -> children ,"Fault" ,envelope_ns );
178178 if (fault != NULL ) {
179179 char * faultcode = NULL ;
180+ zend_string * lang = ZSTR_EMPTY_ALLOC ();
180181 zend_string * faultstring = NULL , * faultactor = NULL ;
181182 zval details ;
182183 xmlNodePtr tmp ;
@@ -219,13 +220,19 @@ bool parse_packet_soap(zval *this_ptr, char *buffer, int buffer_size, sdlFunctio
219220
220221 tmp = get_node (fault -> children ,"Reason" );
221222 if (tmp != NULL && tmp -> children != NULL ) {
222- /* TODO: lang attribute */
223223 tmp = get_node (tmp -> children ,"Text" );
224224 if (tmp != NULL && tmp -> children != NULL ) {
225225 zval zv ;
226226 master_to_zval (& zv , get_conversion (IS_STRING ), tmp );
227227 convert_to_string (& zv )
228228 faultstring = Z_STR (zv );
229+
230+ /* xml:lang is required by SOAP 1.2, but for BC reasons we allow it to be missing */
231+ xmlAttrPtr lang_attr = get_attribute_ex (tmp -> properties , "lang" , (const char * ) XML_XML_NAMESPACE );
232+ if (lang_attr != NULL && lang_attr -> children != NULL ) {
233+ const char * lang_str = (const char * ) lang_attr -> children -> content ;
234+ lang = zend_string_init (lang_str , strlen (lang_str ), false);
235+ }
229236 }
230237 }
231238
@@ -234,13 +241,14 @@ bool parse_packet_soap(zval *this_ptr, char *buffer, int buffer_size, sdlFunctio
234241 master_to_zval (& details , NULL , tmp );
235242 }
236243 }
237- add_soap_fault (this_ptr , faultcode , faultstring ? ZSTR_VAL (faultstring ) : NULL , faultactor ? ZSTR_VAL (faultactor ) : NULL , & details );
244+ add_soap_fault (this_ptr , faultcode , faultstring ? ZSTR_VAL (faultstring ) : NULL , faultactor ? ZSTR_VAL (faultactor ) : NULL , & details , lang );
238245 if (faultstring ) {
239246 zend_string_release_ex (faultstring , 0 );
240247 }
241248 if (faultactor ) {
242249 zend_string_release_ex (faultactor , 0 );
243250 }
251+ zend_string_release_ex (lang , false);
244252 if (Z_REFCOUNTED (details )) {
245253 Z_DELREF (details );
246254 }
0 commit comments