@nuxtjs/mdc 0.13.2 → 0.13.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.json
CHANGED
|
@@ -8,12 +8,28 @@ export const unsafeLinkPrefix = [
|
|
|
8
8
|
"data:text/plain",
|
|
9
9
|
"data:text/xml"
|
|
10
10
|
];
|
|
11
|
+
function isAnchorLinkAllowed(value) {
|
|
12
|
+
const decodedUrl = decodeURIComponent(value);
|
|
13
|
+
const urlSanitized = decodedUrl.replace(/&#x([0-9a-f]+);?/gi, "").replace(/&#(\d+);?/g, "").replace(/&[a-z]+;?/gi, "");
|
|
14
|
+
if (urlSanitized.startsWith("/") || urlSanitized.startsWith("./") || urlSanitized.startsWith("../")) {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
try {
|
|
18
|
+
const url = new URL(urlSanitized);
|
|
19
|
+
if (unsafeLinkPrefix.some((prefix) => url.protocol.toLowerCase().startsWith(prefix))) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
} catch {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
11
27
|
export const validateProp = (attribute, value) => {
|
|
12
28
|
if (attribute.startsWith("on")) {
|
|
13
29
|
return false;
|
|
14
30
|
}
|
|
15
31
|
if (attribute === "href" || attribute === "src") {
|
|
16
|
-
return
|
|
32
|
+
return isAnchorLinkAllowed(value);
|
|
17
33
|
}
|
|
18
34
|
return true;
|
|
19
35
|
};
|