This commit is contained in:
romankko2 committed 2024-06-21 11:53:00 +02:00
commit 650f4dd3ef
1 file changed
+6 -5
+6 -5
View File
@@ -3,16 +3,17 @@ import { Quill } from '@vueup/vue-quill'
export function registerQuillUrlSanitizer() {
const Link = Quill.import('formats/link')
// Extend the protocol whitelist
Link.PROTOCOL_WHITELIST.push('smb', 'fmp', 'radar', 'rdar', 'sms', '\\')
class CustomLinkSanitizer extends Link {
static sanitize(url) {
const sanitizedUrl = super.sanitize(url)
if (!sanitizedUrl || sanitizedUrl === 'about:blank') return sanitizedUrl
const protocolWhhitelist = ['http', 'https', 'mailto', 'tel', 'radar', 'rdar', 'smb', 'sms']
const hasWhitelistedProtocol = protocolWhhitelist.some(function(protocol) {
return sanitizedUrl.startsWith(protocol)
})
const protocolWhitelist = Link.PROTOCOL_WHITELIST
const hasWhitelistedProtocol = protocolWhitelist.some(protocol => sanitizedUrl.startsWith(protocol))
if (hasWhitelistedProtocol) return sanitizedUrl
@@ -20,5 +21,5 @@ export function registerQuillUrlSanitizer() {
}
}
Quill.register(CustomLinkSanitizer, true)
Quill.register('formats/link', CustomLinkSanitizer, true)
}