diff --git a/src/components/SafeLinks.vue b/src/components/SafeLinks.vue new file mode 100644 index 000000000..19d95cbd7 --- /dev/null +++ b/src/components/SafeLinks.vue @@ -0,0 +1,65 @@ + + + diff --git a/src/pages/Details.vue b/src/pages/Details.vue index 05eb84c17..1a4f78b6e 100644 --- a/src/pages/Details.vue +++ b/src/pages/Details.vue @@ -9,9 +9,9 @@
{{ monitor.id }}
- -

- +

+ +

@@ -281,6 +281,7 @@ import Status from "../components/Status.vue"; import Datetime from "../components/Datetime.vue"; import CountUp from "../components/CountUp.vue"; import Uptime from "../components/Uptime.vue"; +import SafeLinks from "../components/SafeLinks.vue"; import Pagination from "v-pagination-3"; const PingChart = defineAsyncComponent(() => import("../components/PingChart.vue")); import Tag from "../components/Tag.vue"; @@ -309,7 +310,8 @@ export default { Tag, CertificateInfo, PrismEditor, - ScreenshotDialog + ScreenshotDialog, + SafeLinks, }, data() { return { @@ -401,19 +403,6 @@ export default { screenshotURL() { return getResBaseURL() + this.monitor.screenshot + "?time=" + this.cacheTime; - }, - - processedDescription() { - if (!this.monitor.description) { - return ""; - } - - const urlPattern = /(\b(?:https?|ftp|file|smb|ssh|telnet|ldap|git):\/\/[-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%=~_|])/gi; - const processed = this.monitor.description.replace( - urlPattern, - url => `${this.escapeHtml(url)}` - ); - return processed; } }, @@ -671,20 +660,6 @@ export default { .replace("https://example.com/api/push/key?status=up&msg=OK&ping=", this.pushURL); this.pushMonitor.code = code; }); - }, - - /** - * Escape HTML - * @param {string} unsafe Unsafe string - * @returns {string} Safe string - */ - escapeHtml(unsafe) { - return unsafe - .replace(/&/g, "&") - .replace(//g, ">") - .replace(/"/g, """) - .replace(/'/g, "'"); } }, };