Skip to content

[XFA] Send URLs as strings, rather than objects (issue 1773) #13417

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 22, 2021

Conversation

Snuffleupagus
Copy link
Collaborator

@Snuffleupagus Snuffleupagus commented May 22, 2021

Given that URLs 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.

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.
@Snuffleupagus
Copy link
Collaborator Author

/botio unittest

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_unittest from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.67.70.0:8877/d9a5b96498960ac/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_unittest from @Snuffleupagus received. Current queue size: 0

Live output at: http://3.101.106.178:8877/0658c37ac2de79b/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/d9a5b96498960ac/output.txt

Total script time: 3.76 mins

  • Unit Tests: Passed

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://3.101.106.178:8877/0658c37ac2de79b/output.txt

Total script time: 5.19 mins

  • Unit Tests: Passed

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.
@@ -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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that for now we shouldn't create an image in case of this.href !== null:

  • the ref can be a path (a name) to an internal picture which is not in the xml stream and we'll handle this case
  • it can be a real http:// link or whatever. In this case, what's the policy ? especially if the url has the file protocol.
  • it can be garbage as you saw it in the mentioned pdf.
    And I've the same question for a tag in xhtml.js.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main objective of the PR was simply to avoid this line completely breaking everything, because of structured cloning errors (since a URL can't be cloned), and further improvements can probably happen elsewhere?

  • it can be a real http:// link or whatever. In this case, what's the policy ? especially if the url has the file protocol.

I'm not sure that we should even attempt to support that case at all, given the possibly security implications of loading arbitrary content; this feels a bit similar to e.g. #13266 (comment).

Copy link
Contributor

@calixteman calixteman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@calixteman calixteman merged commit 0df1a56 into mozilla:master May 22, 2021
@Snuffleupagus Snuffleupagus deleted the xfa-URL-clone branch May 22, 2021 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants