From 0dba468e60dc47ce6f08ace4e5f9d4ff8a7d2167 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sat, 22 May 2021 09:50:25 +0200 Subject: [PATCH 1/2] Don't allow the `LoopbackPort` to "clone" a `URL` Note that `URL`s aren't supported by the structured clone algorithm, see https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm, and any attempt to send a `URL` using `postMessage` is rejected by the browser. Hence, for consistency when workers are disabled, the `LoopbackPort` should obviously also reject any `URL`s. --- src/display/api.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/display/api.js b/src/display/api.js index 062c474b5..ce7bac9d1 100644 --- a/src/display/api.js +++ b/src/display/api.js @@ -1800,7 +1800,10 @@ class LoopbackPort { } return result; } - result = Array.isArray(value) ? [] : {}; + if (value instanceof URL) { + throw new Error(`LoopbackPort.postMessage - cannot clone: ${value}`); + } + result = Array.isArray(value) ? [] : Object.create(null); cloned.set(value, result); // Adding to cache now for cyclic references. // Cloning all value and object properties, however ignoring properties // defined via getter. From ba13bd8c2daa3c6afeb89178aec2d99dccd6135f Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sat, 22 May 2021 09:57:44 +0200 Subject: [PATCH 2/2] [XFA] Send `URL`s as strings, rather than objects (issue 1773) Given that `URL`s aren't supported by the structured clone algorithm, see https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm, the document in issue 1773 will cause the browser to throw `DataCloneError: The object could not be cloned.`-errors and nothing will render. To fix this, we'll instead simply send the stringified version of the `URL` to prevent these errors from occuring. --- src/core/xfa/template.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/xfa/template.js b/src/core/xfa/template.js index e147cd5b8..cf1095093 100644 --- a/src/core/xfa/template.js +++ b/src/core/xfa/template.js @@ -2257,7 +2257,7 @@ class Image extends StringObject { }; if (this.href) { - html.attributes.src = new URL(this.href); + html.attributes.src = new URL(this.href).href; return html; }