Problem/Motivation
VAT module declares properties named like 'vat|de_reduced|07_1983'. The pipe is not allowed in XML elements.
This in a setup using VAT module any restws XML request that contains a price field will error due to a DomError.
Proposed resolution
Make restws ignore such properties.
Remaining tasks
Review patch, commit.
Original report
commerce_product/6977.xml raises exception:
DOMException: Invalid Character Error in DOMDocument->createElement() (line 663 of sites/all/modules/restws/restws.formats.inc). Backtrace:
DOMDocument->createElement('vat|de_reduced|07_1983') restws.formats.inc:663
RestWSFormatXML::addToXML(Object, Object, Object) restws.formats.inc:665
RestWSFormatXML::addToXML(Object, Object, Object) restws.formats.inc:494
RestWSFormatXML->viewResource(Object, '6977', '') restws.module:147
restws_handle_request('view', Object, 'commerce_product', '6977', '') restws.module:365
restws_page_callback('commerce_product')
call_user_func_array('restws_page_callback', Array) menu.inc:519
menu_execute_active_handler() index.php:21
no wonder, the VAT module has keys like 'vat|de_reduced|07_1983' which is no valid xml element.
we can say, "VAT, you shouldn't do this", but given modules use non-machine names let's see if we can do some escaping.
see the json:
"commerce_price": {
"amount": "745",
"amount_decimal": 7.45,
"currency_code": "EUR",
"data": {
"components": [
]
},
"base_price": {
"amount": false,
"currency_code": false,
"data": false
},
"discount": {
"amount": false,
"currency_code": false,
"data": false
},
"fee": {
"amount": false,
"currency_code": false,
"data": false
},
"shipping": {
"amount": false,
"currency_code": false,
"data": false
},
"flat_rate_dhl": {
"amount": false,
"currency_code": false,
"data": false
},
"vat|de_reduced|07_1983": {
"amount": false,
"currency_code": false,
"data": false
},
"vat|de_standard|19_2007": {
"amount": false,
"currency_code": false,
"data": false
}
},
Comments
Comment #2
geek-merlinAfter learning the xml elemen naming rules i don't see a sanse in escaping.
Patch flying in that does the best we can do about that: Ignore properties with illegal names.
Comment #4
geek-merlinOK, the failing tests seem to be the same as without the patch:
https://www.drupal.org/node/1042186/qa
Comment #5
geek-merlinre-testing #2
Comment #6
lokapujyaand a review of course.
Comment #7
geek-merlin