| |
| |
| |
| |
| |
| |
|
|
| |
|
|
| |
| |
|
|
| import DOMPurify from 'dompurify'; |
| import * as tslib from 'tslib'; |
| import 'abortcontroller-polyfill/dist/abortcontroller-polyfill-only'; |
|
|
| window.tslib = tslib; |
|
|
| |
| Object.fromEntries = function fromEntries(it) { |
| return [...it].reduce((result, [key, value]) => { |
| result[key] = value; |
| return result; |
| }, {}); |
| }; |
|
|
| import './jqueryNativeEventTrigger'; |
|
|
| function hasSafeRel(rel: string) { |
| const parts = rel.split(/\s+/); |
| return parts.includes('noopener') && parts.includes('noreferrer'); |
| } |
|
|
| |
| DOMPurify.addHook('afterSanitizeAttributes', (node: Element) => { |
| if (node.hasAttribute('target') |
| && node.getAttribute('target') === '_blank' |
| && (!node.hasAttribute('rel') |
| || !hasSafeRel(node.getAttribute('rel'))) |
| ) { |
| node.removeAttribute('target'); |
| } |
| }); |
|
|
| window.vueSanitize = function vueSanitize(val: unknown): string { |
| return DOMPurify.sanitize(val, { ADD_ATTR: ['target'] }); |
| }; |
|
|
| |
| |
| |
| window.vueSanitizeUrl = function vueSanitizeUrl(url: string): string { |
| return DOMPurify.isValidAttribute('a', 'href', url) ? url : ''; |
| }; |
|
|