adminforth 4.12.2 → 4.12.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
<script setup lang="ts">
|
|
6
6
|
import type { AdminForthResourceColumnCommon, AdminForthResourceFrontend, AdminUser } from '@/types/Common'
|
|
7
|
-
import { protectAgainstXSS } from '@/utils'
|
|
7
|
+
import { protectAgainstXSS } from '@/utils/protectAgainstXSS'
|
|
8
8
|
|
|
9
9
|
const props = defineProps<{
|
|
10
10
|
column: AdminForthResourceColumnCommon
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<script setup lang="ts">
|
|
6
6
|
import { nextTick, onMounted, ref, watch } from 'vue'
|
|
7
7
|
import type { AdminForthResourceColumnCommon, AdminForthResourceFrontend, AdminUser } from '@/types/Common'
|
|
8
|
-
import { protectAgainstXSS } from '@/utils'
|
|
8
|
+
import { protectAgainstXSS } from '@/utils/protectAgainstXSS'
|
|
9
9
|
|
|
10
10
|
const props = defineProps<{
|
|
11
11
|
column: AdminForthResourceColumnCommon
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import DOMPurify from 'dompurify';
|
|
2
|
+
|
|
3
|
+
// only the rich text renderers import this module, so dompurify lands in their lazy chunks; re-exporting it from
|
|
4
|
+
// utils/index.ts would put dompurify back into the first screen, it runs code when its module loads
|
|
5
|
+
export function protectAgainstXSS(value: string) {
|
|
6
|
+
return DOMPurify.sanitize(value, {
|
|
7
|
+
ALLOWED_TAGS: [
|
|
8
|
+
"address","article","aside","footer","header","h1","h2","h3","h4",
|
|
9
|
+
"h5","h6","hgroup","main","nav","section","blockquote","dd","div",
|
|
10
|
+
"dl","dt","figcaption","figure","hr","li","ol","p","pre",
|
|
11
|
+
"ul","a","abbr","b","bdi","bdo","br","cite","code","data","dfn",
|
|
12
|
+
"em","i","kbd","mark","q","rb","rp","rt","rtc","ruby","s","samp",
|
|
13
|
+
"small","span","strong","sub","sup","time","u","var","wbr","caption",
|
|
14
|
+
"col","colgroup","table","tbody","td","tfoot","th","thead","tr",
|
|
15
|
+
"img","video","source"
|
|
16
|
+
],
|
|
17
|
+
ALLOWED_ATTR: [
|
|
18
|
+
"data-list",
|
|
19
|
+
"src","srcset","alt","title","width","height","loading",
|
|
20
|
+
"controls","autoplay","loop","muted","poster","playsinline","type",
|
|
21
|
+
"class","style"
|
|
22
|
+
],
|
|
23
|
+
ALLOW_DATA_ATTR: true,
|
|
24
|
+
ALLOW_ARIA_ATTR: true
|
|
25
|
+
});
|
|
26
|
+
}
|
|
@@ -5,7 +5,6 @@ import router from "../router";
|
|
|
5
5
|
import { useCoreStore } from '../stores/core';
|
|
6
6
|
import { useUserStore } from '../stores/user';
|
|
7
7
|
import adminforth, { useAdminforth } from '../adminforth';
|
|
8
|
-
import DOMPurify from 'dompurify'
|
|
9
8
|
import debounce from 'debounce';
|
|
10
9
|
import type { AdminForthActionFront, AdminForthResourceColumnInputCommon, AdminForthResourceFrontend, Predicate } from '@/types/Common';
|
|
11
10
|
import { i18nInstance } from '../i18n'
|
|
@@ -336,27 +335,31 @@ export function verySimpleHash(str: string): string {
|
|
|
336
335
|
|
|
337
336
|
export { humanifySize } from '../afcl/fileSize';
|
|
338
337
|
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
338
|
+
const PROTECT_AGAINST_XSS_MOVED = `protectAgainstXSS is no longer exported from '@/utils'. It moved to its own module, so DOMPurify is loaded only by the components which sanitize HTML and not on the first screen of every page.
|
|
339
|
+
|
|
340
|
+
Until you change the import, the HTML is shown as plain text with its tags escaped, not rendered.
|
|
341
|
+
|
|
342
|
+
In your custom component replace
|
|
343
|
+
import { protectAgainstXSS } from '@/utils';
|
|
344
|
+
with
|
|
345
|
+
import { protectAgainstXSS } from '@/utils/protectAgainstXSS';
|
|
346
|
+
|
|
347
|
+
If the same import also brings other helpers, keep them in the '@/utils' import and move only protectAgainstXSS, e.g.
|
|
348
|
+
import { callApi, protectAgainstXSS } from '@/utils';
|
|
349
|
+
becomes
|
|
350
|
+
import { callApi } from '@/utils';
|
|
351
|
+
import { protectAgainstXSS } from '@/utils/protectAgainstXSS';`;
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* @deprecated import it from '@/utils/protectAgainstXSS'. Re-exporting the real one here would put DOMPurify back into the
|
|
355
|
+
* first screen, its module runs code when it loads. TODO next major: remove this stub.
|
|
356
|
+
*/
|
|
357
|
+
export function protectAgainstXSS(value: string): string {
|
|
358
|
+
console.error(PROTECT_AGAINST_XSS_MOVED);
|
|
359
|
+
// never hand the unsanitized HTML back, show it as text instead
|
|
360
|
+
const el = document.createElement('div');
|
|
361
|
+
el.textContent = value;
|
|
362
|
+
return el.innerHTML;
|
|
360
363
|
}
|
|
361
364
|
|
|
362
365
|
export function isPolymorphicColumn(column: any): boolean {
|