Skip to content

Commit bdfb039

Browse files
authored
fix(view): disable shadow mode by default to prevent XSS (#891)
1 parent 30f239b commit bdfb039

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/view/hocs/withYfmHtml/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import type {PluginRuntime, TransformMeta} from '../withMermaid/types';
88

99
import {useYfmHtmlBlockRuntime} from './useYfmHtmlBlockRuntime';
1010

11+
export {DEFAULT_HTML_RUNTIME_CONFIG} from './useYfmHtmlBlockRuntime';
12+
1113
export type WithYfmHtmlBlockOptions = {
1214
runtime: PluginRuntime;
1315
};

src/view/hocs/withYfmHtml/useYfmHtmlBlockRuntime.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,18 @@ import {setupRuntimeConfig} from '@diplodoc/html-extension/utils';
33

44
import type {PluginRuntime, TransformMeta} from './types';
55

6+
/**
7+
* Default runtime config with shadow mode disabled for XSS protection.
8+
*/
9+
export const DEFAULT_HTML_RUNTIME_CONFIG: HTMLRuntimeConfig = {
10+
disabledModes: ['shadow'],
11+
};
12+
613
/** @internal */
714
export function useYfmHtmlBlockRuntime(
815
meta: TransformMeta,
916
runtime: PluginRuntime = '_assets/html-extension.js',
10-
htmlRuntimeConfig: HTMLRuntimeConfig = {},
17+
htmlRuntimeConfig: HTMLRuntimeConfig = DEFAULT_HTML_RUNTIME_CONFIG,
1118
) {
1219
if (meta?.script?.includes(runtime)) {
1320
// MAJOR: update html-extension peer on ^2.7.1 and remove optional chain

0 commit comments

Comments
 (0)