Disallow scripts in srcdoc #190
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes elm/html#246
This patch:
<iframe srcdoc="...">into<iframe srcdoc="..." sandbox="allow-downloads allow-forms allow-top-navigation">. In other words, we add a defaultsandboxifsrcdocis used. The interesting thing about thatsandboxvalue is that it doesn’t containallow-scripts, which means that scripts are disallowed. We only allow non-JS powered features, that Elm programmers probably expect to work. This should make this change as non-breaking as we can. Note that Elm programmers can always specifysandboxusingHtml.Attributes.sandboxif they need some other permission.<iframe srcdoc="..." sandbox="..."we make sure thatsandboxdoes not containallow-scripts.sandboxis applied beforesrcdocorsrc, to make sure that the sandbox is in place before executing anything.Performance: This adds an “is iframe” check at creation of every virtual node element. Only for iframes we do an extra iteration through all facts. Pages typically don’t use many iframes, so that extra iteration should not be a problem.
Demo/test cases: