mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 18:12:29 +08:00
Merge pull request #694 from TriliumNext/sirius_patch_1
Add supported link protocols
This commit is contained in:
commit
b7b8ab56e9
@ -258,9 +258,14 @@ function goToLinkExt(evt, hrefLink, $link) {
|
|||||||
} else {
|
} else {
|
||||||
// Enable protocols supported by CKEditor 5 to be clickable.
|
// Enable protocols supported by CKEditor 5 to be clickable.
|
||||||
// Refer to `allowedProtocols` in https://github.com/TriliumNext/trilium-ckeditor5/blob/main/packages/ckeditor5-build-balloon-block/src/ckeditor.ts.
|
// Refer to `allowedProtocols` in https://github.com/TriliumNext/trilium-ckeditor5/blob/main/packages/ckeditor5-build-balloon-block/src/ckeditor.ts.
|
||||||
// Adding `:` to these links might be safer.
|
// And be consistent with `allowedSchemes` in `src\services\html_sanitizer.ts`
|
||||||
const otherAllowedProtocols = ['mailto:', 'tel:', 'sms:', 'sftp:', 'smb:', 'slack:', 'zotero:'];
|
const allowedSchemes = [
|
||||||
if (otherAllowedProtocols.some(protocol => hrefLink.toLowerCase().startsWith(protocol))){
|
'http', 'https', 'ftp', 'ftps', 'mailto', 'data', 'evernote', 'file', 'facetime', 'gemini', 'git',
|
||||||
|
'gopher', 'imap', 'irc', 'irc6', 'jabber', 'jar', 'lastfm', 'ldap', 'ldaps', 'magnet', 'message',
|
||||||
|
'mumble', 'nfs', 'onenote', 'pop', 'rmi', 's3', 'sftp', 'skype', 'sms', 'spotify', 'steam', 'svn', 'udp',
|
||||||
|
'view-source', 'vlc', 'vnc', 'ws', 'wss', 'xmpp', 'jdbc', 'slack', 'tel', 'smb', 'zotero'
|
||||||
|
];
|
||||||
|
if (allowedSchemes.some(protocol => hrefLink.toLowerCase().startsWith(protocol+':'))){
|
||||||
window.open(hrefLink, '_blank');
|
window.open(hrefLink, '_blank');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,11 +55,12 @@ function sanitize(dirtyHtml: string) {
|
|||||||
"*": [ 'class', 'style', 'title', 'src', 'href', 'hash', 'disabled', 'align', 'alt', 'center', 'data-*' ],
|
"*": [ 'class', 'style', 'title', 'src', 'href', 'hash', 'disabled', 'align', 'alt', 'center', 'data-*' ],
|
||||||
"input": [ "type", "checked" ]
|
"input": [ "type", "checked" ]
|
||||||
},
|
},
|
||||||
|
// Be consistent with `allowedSchemes` in `src\public\app\services\link.js`
|
||||||
allowedSchemes: [
|
allowedSchemes: [
|
||||||
'http', 'https', 'ftp', 'ftps', 'mailto', 'data', 'evernote', 'file', 'facetime', 'irc', 'gemini', 'git',
|
'http', 'https', 'ftp', 'ftps', 'mailto', 'data', 'evernote', 'file', 'facetime', 'gemini', 'git',
|
||||||
'gopher', 'imap', 'irc', 'irc6', 'jabber', 'jar', 'lastfm', 'ldap', 'ldaps', 'magnet', 'message',
|
'gopher', 'imap', 'irc', 'irc6', 'jabber', 'jar', 'lastfm', 'ldap', 'ldaps', 'magnet', 'message',
|
||||||
'mumble', 'nfs', 'onenote', 'pop', 'rmi', 's3', 'sftp', 'skype', 'sms', 'spotify', 'steam', 'svn', 'udp',
|
'mumble', 'nfs', 'onenote', 'pop', 'rmi', 's3', 'sftp', 'skype', 'sms', 'spotify', 'steam', 'svn', 'udp',
|
||||||
'view-source', 'vnc', 'ws', 'wss', 'xmpp', 'jdbc', 'slack'
|
'view-source', 'vlc', 'vnc', 'ws', 'wss', 'xmpp', 'jdbc', 'slack', 'tel', 'smb', 'zotero'
|
||||||
],
|
],
|
||||||
nonTextTags: [
|
nonTextTags: [
|
||||||
'head'
|
'head'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user