mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
regression: reverted link checks of malicious scripts
This commit is contained in:
parent
3557bc024b
commit
0082eff4a0
@ -100,11 +100,26 @@ export const CustomLinkExtension = Mark.create<LinkOptions>({
|
||||
},
|
||||
|
||||
parseHTML() {
|
||||
return [{ tag: 'a[href]:not([href *= "javascript:" i])' }];
|
||||
return [
|
||||
{
|
||||
tag: "a[href]",
|
||||
getAttrs: (node) => {
|
||||
if (typeof node === "string" || !(node instanceof HTMLElement)) {
|
||||
return null;
|
||||
}
|
||||
const href = node.getAttribute("href")?.toLowerCase() || "";
|
||||
if (href.startsWith("javascript:") || href.startsWith("data:") || href.startsWith("vbscript:")) {
|
||||
return false;
|
||||
}
|
||||
return {};
|
||||
},
|
||||
},
|
||||
];
|
||||
},
|
||||
|
||||
renderHTML({ HTMLAttributes }) {
|
||||
if (HTMLAttributes.href?.startsWith("javascript:")) {
|
||||
const href = HTMLAttributes.href?.toLowerCase() || "";
|
||||
if (href.startsWith("javascript:") || href.startsWith("data:") || href.startsWith("vbscript:")) {
|
||||
return ["a", mergeAttributes(this.options.HTMLAttributes, { ...HTMLAttributes, href: "" }), 0];
|
||||
}
|
||||
return ["a", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
|
||||
|
Loading…
Reference in New Issue
Block a user