mirror of
https://git.proxmox.com/git/proxmox-widget-toolkit
synced 2025-05-22 22:00:18 +00:00
markdown parser: allow setting target tag for links
If one really want's to force a link to open in a new tab (or window, depending on the browser settings). Note that we don't set target to _blank by default for links, as opening in a new tab can already simply be done via a middle-click on the link without that, but once the target is set opening in the same tab cannot easily be done, i.e., without a target set the reader has more freedom and flexibility. Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
5cbbb9c44a
commit
2d04f0165d
@ -26,7 +26,7 @@ Ext.define('Proxmox.Markdown', {
|
|||||||
const value = node.attributes[i].value;
|
const value = node.attributes[i].value;
|
||||||
// TODO: we may want to also disallow class and id attrs
|
// TODO: we may want to also disallow class and id attrs
|
||||||
if (
|
if (
|
||||||
!/^(class|id|name|href|src|alt|align|valign|disabled|checked|start|type)$/i.test(name)
|
!/^(class|id|name|href|src|alt|align|valign|disabled|checked|start|type|target)$/i.test(name)
|
||||||
) {
|
) {
|
||||||
node.attributes.removeNamedItem(name);
|
node.attributes.removeNamedItem(name);
|
||||||
} else if ((name === 'href' || name === 'src') && !_isHTTPLike(value)) {
|
} else if ((name === 'href' || name === 'src') && !_isHTTPLike(value)) {
|
||||||
@ -44,6 +44,8 @@ Ext.define('Proxmox.Markdown', {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
node.attributes.removeNamedItem(name);
|
node.attributes.removeNamedItem(name);
|
||||||
}
|
}
|
||||||
|
} else if (name === 'target' && node.tagName.toLowerCase() !== 'a') {
|
||||||
|
node.attributes.removeNamedItem(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (let i=node.childNodes.length; i--;) _sanitize(node.childNodes[i]);
|
for (let i=node.childNodes.length; i--;) _sanitize(node.childNodes[i]);
|
||||||
|
Loading…
Reference in New Issue
Block a user