@@ -904,52 +904,52 @@ PHP_METHOD(DOM_Document, createAttributeNS)
904
904
root = xmlDocGetRootElement (docp );
905
905
if (root != NULL ) {
906
906
errorcode = dom_check_qname (ZSTR_VAL (name ), & localname , & prefix , uri_len , ZSTR_LEN (name ));
907
- /* TODO: switch to early goto-out style error-checking */
908
- if (errorcode == 0 ) {
909
- if (xmlValidateName ((xmlChar * ) localname , 0 ) == 0 ) {
910
- /* If prefix is "xml" and namespace is not the XML namespace, then throw a "NamespaceError" DOMException. */
911
- if (UNEXPECTED (!zend_string_equals_literal (uri , "http://www.w3.org/XML/1998/namespace" ) && xmlStrEqual (BAD_CAST prefix , BAD_CAST "xml" ))) {
912
- errorcode = NAMESPACE_ERR ;
913
- goto error ;
914
- }
915
- /* If either qualifiedName or prefix is "xmlns" and namespace is not the XMLNS namespace, then throw a "NamespaceError" DOMException. */
916
- if (UNEXPECTED ((zend_string_equals_literal (name , "xmlns" ) || xmlStrEqual (BAD_CAST prefix , BAD_CAST "xmlns" )) && !zend_string_equals_literal (uri , "http://www.w3.org/2000/xmlns/" ))) {
917
- errorcode = NAMESPACE_ERR ;
918
- goto error ;
919
- }
920
- /* If namespace is the XMLNS namespace and neither qualifiedName nor prefix is "xmlns", then throw a "NamespaceError" DOMException. */
921
- if (UNEXPECTED (zend_string_equals_literal (uri , "http://www.w3.org/2000/xmlns/" ) && !zend_string_equals_literal (name , "xmlns" ) && !xmlStrEqual (BAD_CAST prefix , BAD_CAST "xmlns" ))) {
922
- errorcode = NAMESPACE_ERR ;
923
- goto error ;
924
- }
907
+ if (UNEXPECTED (errorcode != 0 )) {
908
+ goto error ;
909
+ }
910
+ if (UNEXPECTED (xmlValidateName ((xmlChar * ) localname , 0 ) != 0 )) {
911
+ errorcode = INVALID_CHARACTER_ERR ;
912
+ goto error ;
913
+ }
914
+ /* If prefix is "xml" and namespace is not the XML namespace, then throw a "NamespaceError" DOMException. */
915
+ if (UNEXPECTED (!zend_string_equals_literal (uri , "http://www.w3.org/XML/1998/namespace" ) && xmlStrEqual (BAD_CAST prefix , BAD_CAST "xml" ))) {
916
+ errorcode = NAMESPACE_ERR ;
917
+ goto error ;
918
+ }
919
+ /* If either qualifiedName or prefix is "xmlns" and namespace is not the XMLNS namespace, then throw a "NamespaceError" DOMException. */
920
+ if (UNEXPECTED ((zend_string_equals_literal (name , "xmlns" ) || xmlStrEqual (BAD_CAST prefix , BAD_CAST "xmlns" )) && !zend_string_equals_literal (uri , "http://www.w3.org/2000/xmlns/" ))) {
921
+ errorcode = NAMESPACE_ERR ;
922
+ goto error ;
923
+ }
924
+ /* If namespace is the XMLNS namespace and neither qualifiedName nor prefix is "xmlns", then throw a "NamespaceError" DOMException. */
925
+ if (UNEXPECTED (zend_string_equals_literal (uri , "http://www.w3.org/2000/xmlns/" ) && !zend_string_equals_literal (name , "xmlns" ) && !xmlStrEqual (BAD_CAST prefix , BAD_CAST "xmlns" ))) {
926
+ errorcode = NAMESPACE_ERR ;
927
+ goto error ;
928
+ }
925
929
926
- nodep = (xmlNodePtr ) xmlNewDocProp (docp , (xmlChar * ) localname , NULL );
927
- if (UNEXPECTED (nodep == NULL )) {
928
- php_dom_throw_error (INVALID_STATE_ERR , /* strict */ true);
929
- RETURN_THROWS ();
930
- }
930
+ nodep = (xmlNodePtr ) xmlNewDocProp (docp , (xmlChar * ) localname , NULL );
931
+ if (UNEXPECTED (nodep == NULL )) {
932
+ php_dom_throw_error (INVALID_STATE_ERR , /* strict */ true);
933
+ RETURN_THROWS ();
934
+ }
931
935
932
- if (uri_len > 0 ) {
933
- nsptr = xmlSearchNsByHref (docp , root , BAD_CAST ZSTR_VAL (uri ));
934
-
935
- if (zend_string_equals_literal (name , "xmlns" ) || xmlStrEqual (BAD_CAST prefix , BAD_CAST "xml" )) {
936
- if (nsptr == NULL ) {
937
- nsptr = xmlNewNs (NULL , BAD_CAST ZSTR_VAL (uri ), BAD_CAST prefix );
938
- php_libxml_set_old_ns (docp , nsptr );
939
- }
940
- } else {
941
- if (nsptr == NULL || nsptr -> prefix == NULL ) {
942
- nsptr = dom_get_ns_unchecked (root , ZSTR_VAL (uri ), prefix ? prefix : "default" );
943
- if (UNEXPECTED (nsptr == NULL )) {
944
- errorcode = NAMESPACE_ERR ;
945
- }
946
- }
947
- }
948
- xmlSetNs (nodep , nsptr );
936
+ if (uri_len > 0 ) {
937
+ nsptr = xmlSearchNsByHref (docp , root , BAD_CAST ZSTR_VAL (uri ));
938
+
939
+ if (zend_string_equals_literal (name , "xmlns" ) || xmlStrEqual (BAD_CAST prefix , BAD_CAST "xml" )) {
940
+ if (nsptr == NULL ) {
941
+ nsptr = xmlNewNs (NULL , BAD_CAST ZSTR_VAL (uri ), BAD_CAST prefix );
942
+ php_libxml_set_old_ns (docp , nsptr );
949
943
}
950
944
} else {
951
- errorcode = INVALID_CHARACTER_ERR ;
945
+ if (nsptr == NULL || nsptr -> prefix == NULL ) {
946
+ nsptr = dom_get_ns_unchecked (root , ZSTR_VAL (uri ), prefix ? prefix : "default" );
947
+ if (UNEXPECTED (nsptr == NULL )) {
948
+ errorcode = NAMESPACE_ERR ;
949
+ }
950
+ }
952
951
}
952
+ xmlSetNs (nodep , nsptr );
953
953
}
954
954
} else {
955
955
php_error_docref (NULL , E_WARNING , "Document Missing Root Element" );
0 commit comments