15685: Fixes file name encoding/decoding handling on webdav.
authorLucas Di Pentima <lucas@di-pentima.com.ar>
Tue, 10 Nov 2020 15:58:15 +0000 (12:58 -0300)
committerLucas Di Pentima <lucas@di-pentima.com.ar>
Tue, 10 Nov 2020 15:58:15 +0000 (12:58 -0300)
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas@di-pentima.com.ar>

src/common/webdav.ts
src/common/xml.ts

index b51cff30703ea51b392b87a2998f9607f052c5a3..c4d8acaea2e8a58f090b21d6b4b8dc48a31c0e49 100644 (file)
@@ -75,7 +75,7 @@ export class WebDAV {
             r.open(config.method,
                 `${this.defaults.baseURL
                     ? this.defaults.baseURL+'/'
-                    : ''}${config.url}`);
+                    : ''}${encodeURI(config.url)}`);
             const headers = { ...this.defaults.headers, ...config.headers };
             Object
                 .keys(headers)
index 098f27818a85c6406445f08770231909ea400c62..3c6feb5dce8836a92a08074ba32a768af4ec84fc 100644 (file)
@@ -4,5 +4,16 @@
 
 export const getTagValue = (document: Document | Element, tagName: string, defaultValue: string) => {
     const [el] = Array.from(document.getElementsByTagName(tagName));
-    return decodeURI(el ? el.innerHTML : defaultValue);
+    return decodeURI(el ? htmlDecode(el.innerHTML) : defaultValue);
+};
+
+const htmlDecode = (input: string) => {
+    const out = input.split(' ').map((i) => {
+        const doc = new DOMParser().parseFromString(i, "text/html");
+        if (doc.documentElement !== null) {
+            return doc.documentElement.textContent || '';
+        }
+        return '';
+    });
+    return out.join(' ');
 };