mirror of
https://bitbucket.org/studiotem/jandl-taskmanager-app.git
synced 2026-10-21 14:29:34 +00:00
[bugfix] quill link protocol
This commit is contained in:
1 parent
0a4c2ef44a
commit
057128889d
2 files changed
+26
No files matched your search
@@ -2,6 +2,7 @@ import { createApp } from 'vue'
|
||||
import { IonicVue } from '@ionic/vue'
|
||||
import { loadFonts } from './webfontloader'
|
||||
import vuetify from './vuetify'
|
||||
import { registerQuillUrlSanitizer } from './quill.util'
|
||||
import loader from 'vue-loading-overlay'
|
||||
import App from './App.vue'
|
||||
|
||||
@@ -29,6 +30,7 @@ import 'vue-loading-overlay/dist/vue-loading.css'
|
||||
import '@vuepic/vue-datepicker/dist/main.css'
|
||||
|
||||
loadFonts()
|
||||
registerQuillUrlSanitizer()
|
||||
|
||||
const options: Options = {
|
||||
axios: {
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
import { Quill } from '@vueup/vue-quill'
|
||||
|
||||
export function registerQuillUrlSanitizer() {
|
||||
const Link = Quill.import('formats/link')
|
||||
|
||||
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)
|
||||
})
|
||||
|
||||
if (hasWhitelistedProtocol) return sanitizedUrl
|
||||
|
||||
return `https://${sanitizedUrl}`
|
||||
}
|
||||
}
|
||||
|
||||
Quill.register(CustomLinkSanitizer, true)
|
||||
}
|
||||
Reference in new issue
Block a user