Skip to content

Commit 4dbcd36

Browse files
committed
remove helpers
1 parent 316496a commit 4dbcd36

3 files changed

Lines changed: 27 additions & 45 deletions

File tree

NEWS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ PHP NEWS
8080
do_request() parameters). (David Carlier)
8181
. Fixed xsd:hexBinary decoding to reject odd-length values instead of
8282
silently truncating the last nibble. (Weilin Du)
83-
. Made SOAP scalar decoding errors report the affected type instead of the
84-
generic "Violation of encoding rules" message. (Weilin Du)
83+
. Made SOAP encoding errors report the affected type or failing operation
84+
instead of the generic "Violation of encoding rules" message. (Weilin Du)
8585

8686
- Standard:
8787
. Fixed sleep() and usleep() to reject values that overflow the underlying

UPGRADING

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,10 @@ PHP 8.6 UPGRADE NOTES
147147
. WSDL/XML Schema parsing now rejects out-of-range integer values for
148148
occurrence constraints and integer restriction facets. Negative minOccurs
149149
and maxOccurs values are rejected as well.
150-
. Scalar decoding errors now report the affected type and specific
151-
validation failure in SoapFault::faultstring instead of the generic
152-
"Encoding: Violation of encoding rules" message. Code that compares the
153-
exact fault string may need to be updated.
150+
. SOAP encoding errors now report the affected type or failing operation in
151+
the error message instead of the generic "Encoding: Violation of encoding
152+
rules" message. Code that compares the exact message may need to be
153+
updated.
154154

155155
- Sodium:
156156
. The password-hashing functions sodium_crypto_pwhash(),

ext/soap/php_encoding.c

Lines changed: 21 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -87,28 +87,6 @@ static zend_always_inline const char *soap_type_name(encodeTypePtr type)
8787
return (type && type->type_str) ? type->type_str : "unknown";
8888
}
8989

90-
static zend_always_inline void soap_encoding_error_invalid_node(encodeTypePtr type)
91-
{
92-
soap_error1(E_ERROR, "Encoding: Type '%s' value must contain a single text or CDATA node", soap_type_name(type));
93-
}
94-
95-
static zend_always_inline void soap_encoding_error_invalid_value(encodeTypePtr type)
96-
{
97-
soap_error1(E_ERROR, "Encoding: Invalid value for type '%s'", soap_type_name(type));
98-
}
99-
100-
static zend_always_inline void soap_encoding_error_invalid_hex_length(encodeTypePtr type)
101-
{
102-
soap_error1(E_ERROR, "Encoding: Type '%s' value must contain an even number of hexadecimal digits", soap_type_name(type));
103-
}
104-
105-
static zend_always_inline void soap_encoding_error_invalid_list_item(encodeTypePtr type, encodeTypePtr item_type)
106-
{
107-
soap_error2(E_ERROR,
108-
"Encoding: Failed to encode list item of type '%s' for list type '%s'",
109-
soap_type_name(item_type), soap_type_name(type));
110-
}
111-
11290
static encodePtr get_array_type(xmlNodePtr node, zval *array, smart_str *out_type);
11391

11492
static xmlNodePtr check_and_resolve_href(xmlNodePtr data);
@@ -687,7 +665,7 @@ static zval *to_zval_string(zval *ret, encodeTypePtr type, xmlNodePtr data)
687665
} else if (data->children->type == XML_CDATA_SECTION_NODE && data->children->next == NULL) {
688666
ZVAL_STRING(ret, (char*)data->children->content);
689667
} else {
690-
soap_encoding_error_invalid_node(type);
668+
soap_error1(E_ERROR, "Encoding: Type '%s' value must contain a single text or CDATA node", soap_type_name(type));
691669
}
692670
} else {
693671
ZVAL_EMPTY_STRING(ret);
@@ -720,7 +698,7 @@ static zval *to_zval_stringr(zval *ret, encodeTypePtr type, xmlNodePtr data)
720698
} else if (data->children->type == XML_CDATA_SECTION_NODE && data->children->next == NULL) {
721699
ZVAL_STRING(ret, (char*)data->children->content);
722700
} else {
723-
soap_encoding_error_invalid_node(type);
701+
soap_error1(E_ERROR, "Encoding: Type '%s' value must contain a single text or CDATA node", soap_type_name(type));
724702
}
725703
} else {
726704
ZVAL_EMPTY_STRING(ret);
@@ -753,7 +731,7 @@ static zval *to_zval_stringc(zval *ret, encodeTypePtr type, xmlNodePtr data)
753731
} else if (data->children->type == XML_CDATA_SECTION_NODE && data->children->next == NULL) {
754732
ZVAL_STRING(ret, (char*)data->children->content);
755733
} else {
756-
soap_encoding_error_invalid_node(type);
734+
soap_error1(E_ERROR, "Encoding: Type '%s' value must contain a single text or CDATA node", soap_type_name(type));
757735
}
758736
} else {
759737
ZVAL_EMPTY_STRING(ret);
@@ -772,17 +750,17 @@ static zval *to_zval_base64(zval *ret, encodeTypePtr type, xmlNodePtr data)
772750
whiteSpace_collapse(data->children->content);
773751
str = php_base64_decode(data->children->content, strlen((char*)data->children->content));
774752
if (!str) {
775-
soap_encoding_error_invalid_value(type);
753+
soap_error1(E_ERROR, "Encoding: Invalid value for type '%s'", soap_type_name(type));
776754
}
777755
ZVAL_STR(ret, str);
778756
} else if (data->children->type == XML_CDATA_SECTION_NODE && data->children->next == NULL) {
779757
str = php_base64_decode(data->children->content, strlen((char*)data->children->content));
780758
if (!str) {
781-
soap_encoding_error_invalid_value(type);
759+
soap_error1(E_ERROR, "Encoding: Invalid value for type '%s'", soap_type_name(type));
782760
}
783761
ZVAL_STR(ret, str);
784762
} else {
785-
soap_encoding_error_invalid_node(type);
763+
soap_error1(E_ERROR, "Encoding: Type '%s' value must contain a single text or CDATA node", soap_type_name(type));
786764
}
787765
} else {
788766
ZVAL_EMPTY_STRING(ret);
@@ -803,12 +781,12 @@ static zval *to_zval_hexbin(zval *ret, encodeTypePtr type, xmlNodePtr data)
803781
if (data->children->type == XML_TEXT_NODE && data->children->next == NULL) {
804782
whiteSpace_collapse(data->children->content);
805783
} else if (data->children->type != XML_CDATA_SECTION_NODE || data->children->next != NULL) {
806-
soap_encoding_error_invalid_node(type);
784+
soap_error1(E_ERROR, "Encoding: Type '%s' value must contain a single text or CDATA node", soap_type_name(type));
807785
return ret;
808786
}
809787
content_len = strlen((char*) data->children->content);
810788
if (content_len % 2 != 0) {
811-
soap_encoding_error_invalid_hex_length(type);
789+
soap_error1(E_ERROR, "Encoding: Type '%s' value must contain an even number of hexadecimal digits", soap_type_name(type));
812790
return ret;
813791
}
814792
str = zend_string_alloc(content_len / 2, 0);
@@ -821,7 +799,7 @@ static zval *to_zval_hexbin(zval *ret, encodeTypePtr type, xmlNodePtr data)
821799
} else if (c >= 'A' && c <= 'F') {
822800
ZSTR_VAL(str)[i] = (c - 'A' + 10) << 4;
823801
} else {
824-
soap_encoding_error_invalid_value(type);
802+
soap_error1(E_ERROR, "Encoding: Invalid value for type '%s'", soap_type_name(type));
825803
}
826804
c = data->children->content[j++];
827805
if (c >= '0' && c <= '9') {
@@ -831,7 +809,7 @@ static zval *to_zval_hexbin(zval *ret, encodeTypePtr type, xmlNodePtr data)
831809
} else if (c >= 'A' && c <= 'F') {
832810
ZSTR_VAL(str)[i] |= c - 'A' + 10;
833811
} else {
834-
soap_encoding_error_invalid_value(type);
812+
soap_error1(E_ERROR, "Encoding: Invalid value for type '%s'", soap_type_name(type));
835813
}
836814
}
837815
ZSTR_VAL(str)[ZSTR_LEN(str)] = '\0';
@@ -1052,11 +1030,11 @@ static zval *to_zval_double(zval *ret, encodeTypePtr type, xmlNodePtr data)
10521030
} else if (strncasecmp((char*)data->children->content, "-INF", sizeof("-INF")-1) == 0) {
10531031
ZVAL_DOUBLE(ret, -php_get_inf());
10541032
} else {
1055-
soap_encoding_error_invalid_value(type);
1033+
soap_error1(E_ERROR, "Encoding: Invalid value for type '%s'", soap_type_name(type));
10561034
}
10571035
}
10581036
} else {
1059-
soap_encoding_error_invalid_node(type);
1037+
soap_error1(E_ERROR, "Encoding: Type '%s' value must contain a single text or CDATA node", soap_type_name(type));
10601038
}
10611039
} else {
10621040
ZVAL_NULL(ret);
@@ -1085,10 +1063,10 @@ static zval *to_zval_long(zval *ret, encodeTypePtr type, xmlNodePtr data)
10851063
ZVAL_DOUBLE(ret, dval);
10861064
break;
10871065
default:
1088-
soap_encoding_error_invalid_value(type);
1066+
soap_error1(E_ERROR, "Encoding: Invalid value for type '%s'", soap_type_name(type));
10891067
}
10901068
} else {
1091-
soap_encoding_error_invalid_node(type);
1069+
soap_error1(E_ERROR, "Encoding: Type '%s' value must contain a single text or CDATA node", soap_type_name(type));
10921070
}
10931071
} else {
10941072
ZVAL_NULL(ret);
@@ -1154,7 +1132,7 @@ static zval *to_zval_bool(zval *ret, encodeTypePtr type, xmlNodePtr data)
11541132
}
11551133
if (data->children->type != XML_TEXT_NODE || data->children->next != NULL) {
11561134
// TODO Convert to exception?
1157-
soap_encoding_error_invalid_node(type);
1135+
soap_error1(E_ERROR, "Encoding: Type '%s' value must contain a single text or CDATA node", soap_type_name(type));
11581136
}
11591137

11601138
whiteSpace_collapse(data->children->content);
@@ -3123,7 +3101,9 @@ static xmlNodePtr to_xml_list(encodeTypePtr enc, zval *data, int style, xmlNodeP
31233101
}
31243102
smart_str_appends(&list, (char*)dummy->children->content);
31253103
} else {
3126-
soap_encoding_error_invalid_list_item(enc, &list_enc->details);
3104+
soap_error2(E_ERROR,
3105+
"Encoding: Failed to encode list item of type '%s' for list type '%s'",
3106+
soap_type_name(&list_enc->details), soap_type_name(enc));
31273107
}
31283108
xmlUnlinkNode(dummy);
31293109
xmlFreeNode(dummy);
@@ -3165,7 +3145,9 @@ static xmlNodePtr to_xml_list(encodeTypePtr enc, zval *data, int style, xmlNodeP
31653145
}
31663146
smart_str_appends(&list, (char*)dummy->children->content);
31673147
} else {
3168-
soap_encoding_error_invalid_list_item(enc, &list_enc->details);
3148+
soap_error2(E_ERROR,
3149+
"Encoding: Failed to encode list item of type '%s' for list type '%s'",
3150+
soap_type_name(&list_enc->details), soap_type_name(enc));
31693151
}
31703152
xmlUnlinkNode(dummy);
31713153
xmlFreeNode(dummy);

0 commit comments

Comments
 (0)