webdav-client
webdav-client copied to clipboard
strange parsing of multistatus, namespaces not stripped
Hello and thank you for a great tool! I have a legacy webdav server and the following strange multistatus parsing error occurs:
XML:
<?xml version="1.0" encoding="utf-8"?>
<A:multistatus xmlns:A="DAV:" xmlns:B="http://sap.com/kpro/xmlns">
<A:response><A:href>/sql_http_api/mime/SAP/PUBLIC/open_sql_rest_parser/</A:href>
<A:propstat><A:status>HTTP/1.1 200 OK</A:status><A:prop><B:CREATED_AT>20230314094415</B:CREATED_AT><B:CREATED_BY>DEVELOPER</B:CREATED_BY><B:DESCRIPTION>open sql rest parser</B:DESCRIPTION><B:FOLDER_ROLE/><B:KW_AUTHORIZATION/><B:KW_PARENT_FOLDER_CLASS>M_FOLDER</B:KW_PARENT_FOLDER_CLASS><B:KW_PARENT_FOLDER_ID>… 1-</B:MIME_CACHE_EXPIRY><A:displayname>tests</A:displayname><A:resourcetype><A:collection/></A:resourcetype><A:getetag>080027E861FB1EEDB0C99A7B81858A5D</A:getetag><A:getcontentlength>0 </A:getcontentlength><A:getcontenttype>text/html; charset=utf-8</A:getcontenttype><A:creationdate>2023-03-14T09:44:36Z</A:creationdate><A:getlastmodified>Tue, 14 Mar 2023 09:44:36 GMT</A:getlastmodified>
<A:lockdiscovery/>
<A:supportedlock/>
</A:prop>
</A:propstat>
</A:response>
</A:multistatus>
However, JSON of the js response from fastxml is contains namespaces: (reduced for readability)
{
"multistatus\nxmlns:A=\"DAV:\"\nxmlns:B=\"http://sap.com/kpro/xmlns\"": {
"response": [
{
"href": "/sql_http_api/mime/SAP/PUBLIC/open_sql_rest_parser/",
"propstat": {
.......
source code clearly indicates that namespaces should be stripped:
const result = xmlParser.parse(xml, {
arrayMode: false,
ignoreNameSpace: true
// // We don't use the processors here as decoding is done manually
// // later on - decoding early would break some path checks.
// attrValueProcessor: val => decodeHTMLEntities(decodeURIComponent(val)),
// tagValueProcessor: val => decodeHTMLEntities(decodeURIComponent(val))
});
I'm unsure if this is a fastxml or webdav-client bug. Or possibly that I need to add some namespace definitions on the server side.
Many thanks!
Hi! Have you tried v5.2.0 of this library, if you're still having this issue? I understand it was some time ago.