[FIX] web_editor: prevent zws in url on paste
Paste a url in the editor from the URL bar of the browser. If you then select it all and paste another URL in its stead, the zws inserted by the sanitizer when deleting the selection ends up in the URL. This is because the sanitizer moves downward into the DOM tree, therefore change the link URL before removing the zws in its text child node. To make sure this can't ever happen, we now remove zws from URLs when parsing them from the link's text content. task-3054233 closes odoo/odoo#105045 X-original-commit: c4c9627297c0e3e3977cbfd51129227f8ec1ce3c Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
This commit is contained in:
@@ -220,7 +220,10 @@ class Sanitize {
|
||||
) {
|
||||
node.setAttribute('contenteditable', 'false');
|
||||
}
|
||||
// update link URL if label is a new valid link
|
||||
if (node.firstChild) {
|
||||
this._parse(node.firstChild);
|
||||
}
|
||||
// Update link URL if label is a new valid link.
|
||||
if (node.nodeName === 'A' && anchorEl === node) {
|
||||
const linkLabel = node.textContent;
|
||||
const match = linkLabel.match(URL_REGEX);
|
||||
@@ -229,9 +232,6 @@ class Sanitize {
|
||||
node.setAttribute('href', urlInfo.url);
|
||||
}
|
||||
}
|
||||
if (node.firstChild) {
|
||||
this._parse(node.firstChild);
|
||||
}
|
||||
node = node.nextSibling;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user