Sanitize style elements in clipboard markup
This patch sanitizes clipboard markup before pasting it into document by removing all pasted style elements and serializing them onto elements as inline style. In this way, we stop stylesheets in clipboard markup from being applied to the original elements in the document. This patch follows the same approach as in WebKit [1]: - First create a dummy document to insert the markup - Then computes style and layout in the dummy document - Re-serialize the dummy document as the markup to be inserted. This reuses the code path that we serialize a selection range into clipboard, where we need to serialize element computed style into inline styles so that the element styles are preserved. - Make sure all style elements are removed before inserting markup into document This patch also adds a complete test to ensure that content pasted from Excel is still properly styled, which is the main reason we used to preserve style elements in clipboard markup [2]. [1] https://trac.webkit.org/changeset/223440 [2] http://crbug.com/121163 Bug: 1017871 Change-Id: I3bb5a4ae7530a3fdef5ba251975e004857c06f1e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1922919 Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org> Reviewed-by:Yoshifumi Inoue <yosin@chromium.org> Reviewed-by:
Kent Tamura <tkent@chromium.org> Cr-Commit-Position: refs/heads/master@{#718281}
Showing
Please register or sign in to comment