|
|
@@ -327,20 +327,15 @@ export const generateViewOptions = (
|
|
|
remarkPlugins.push(breaks);
|
|
|
}
|
|
|
|
|
|
+ const rehypeSanitizePlugin: Pluggable<any[]> | (() => void) = config.isEnabledXssPrevention
|
|
|
+ ? [sanitize, deepmerge(commonSanitizeOption, lsxGrowiPlugin.sanitizeOption)]
|
|
|
+ : () => {};
|
|
|
+
|
|
|
// add rehype plugins
|
|
|
rehypePlugins.push(
|
|
|
slug,
|
|
|
[lsxGrowiPlugin.rehypePlugin, { pagePath }],
|
|
|
- );
|
|
|
- if (config.isEnabledXssPrevention) {
|
|
|
- rehypePlugins.push(
|
|
|
- [sanitize, deepmerge(
|
|
|
- commonSanitizeOption,
|
|
|
- lsxGrowiPlugin.sanitizeOption,
|
|
|
- )],
|
|
|
- );
|
|
|
- }
|
|
|
- rehypePlugins.push(
|
|
|
+ rehypeSanitizePlugin,
|
|
|
katex,
|
|
|
[toc.rehypePluginStore, { storeTocNode }],
|
|
|
// [autoLinkHeadings, {
|
|
|
@@ -383,15 +378,16 @@ export const generateTocOptions = (config: RendererConfig, tocNode: HtmlElementN
|
|
|
// add remark plugins
|
|
|
// remarkPlugins.push();
|
|
|
|
|
|
+
|
|
|
+ const rehypeSanitizePlugin: Pluggable<any[]> | (() => void) = config.isEnabledXssPrevention
|
|
|
+ ? [sanitize, deepmerge(commonSanitizeOption, lsxGrowiPlugin.sanitizeOption)]
|
|
|
+ : () => {};
|
|
|
+
|
|
|
// add rehype plugins
|
|
|
rehypePlugins.push(
|
|
|
[toc.rehypePluginRestore, { tocNode }],
|
|
|
+ rehypeSanitizePlugin,
|
|
|
);
|
|
|
- if (config.isEnabledXssPrevention) {
|
|
|
- rehypePlugins.push(
|
|
|
- [sanitize, commonSanitizeOption],
|
|
|
- );
|
|
|
- }
|
|
|
// renderer.rehypePlugins.push([autoLinkHeadings, {
|
|
|
// behavior: 'append',
|
|
|
// }]);
|
|
|
@@ -418,20 +414,15 @@ export const generateSimpleViewOptions = (config: RendererConfig, pagePath: stri
|
|
|
remarkPlugins.push(breaks);
|
|
|
}
|
|
|
|
|
|
+ const rehypeSanitizePlugin: Pluggable<any[]> | (() => void) = config.isEnabledXssPrevention
|
|
|
+ ? [sanitize, deepmerge(commonSanitizeOption, lsxGrowiPlugin.sanitizeOption)]
|
|
|
+ : () => {};
|
|
|
+
|
|
|
// add rehype plugins
|
|
|
rehypePlugins.push(
|
|
|
[lsxGrowiPlugin.rehypePlugin, { pagePath }],
|
|
|
[keywordHighlighter.rehypePlugin, { keywords: highlightKeywords }],
|
|
|
- );
|
|
|
- if (config.isEnabledXssPrevention) {
|
|
|
- rehypePlugins.push(
|
|
|
- [sanitize, deepmerge(
|
|
|
- commonSanitizeOption,
|
|
|
- lsxGrowiPlugin.sanitizeOption,
|
|
|
- )],
|
|
|
- );
|
|
|
- }
|
|
|
- rehypePlugins.push(
|
|
|
+ rehypeSanitizePlugin,
|
|
|
katex,
|
|
|
);
|
|
|
|
|
|
@@ -462,19 +453,15 @@ export const generatePreviewOptions = (config: RendererConfig, pagePath: string)
|
|
|
remarkPlugins.push(breaks);
|
|
|
}
|
|
|
|
|
|
+ const rehypeSanitizePlugin: Pluggable<any[]> | (() => void) = config.isEnabledXssPrevention
|
|
|
+ ? [sanitize, deepmerge(commonSanitizeOption, lsxGrowiPlugin.sanitizeOption)]
|
|
|
+ : () => {};
|
|
|
+
|
|
|
// add rehype plugins
|
|
|
rehypePlugins.push(
|
|
|
[lsxGrowiPlugin.rehypePlugin, { pagePath }],
|
|
|
addLineNumberAttribute.rehypePlugin,
|
|
|
- );
|
|
|
- if (config.isEnabledXssPrevention) {
|
|
|
- rehypePlugins.push([sanitize, deepmerge(
|
|
|
- commonSanitizeOption,
|
|
|
- lsxGrowiPlugin.sanitizeOption,
|
|
|
- addLineNumberAttribute.sanitizeOption,
|
|
|
- )]);
|
|
|
- }
|
|
|
- rehypePlugins.push(
|
|
|
+ rehypeSanitizePlugin,
|
|
|
katex,
|
|
|
);
|
|
|
// add components
|
|
|
@@ -498,12 +485,15 @@ export const generateOthersOptions = (config: RendererConfig): RendererOptions =
|
|
|
// renderer.setMarkdownSettings({ breaks: rendererSettings.isEnabledLinebreaks });
|
|
|
// renderer.configure();
|
|
|
|
|
|
+
|
|
|
+ const rehypeSanitizePlugin: Pluggable<any[]> | (() => void) = config.isEnabledXssPrevention
|
|
|
+ ? [sanitize, deepmerge(commonSanitizeOption, lsxGrowiPlugin.sanitizeOption)]
|
|
|
+ : () => {};
|
|
|
+
|
|
|
// add rehype plugins
|
|
|
- if (config.isEnabledXssPrevention) {
|
|
|
- rehypePlugins.push(
|
|
|
- [sanitize, commonSanitizeOption],
|
|
|
- );
|
|
|
- }
|
|
|
+ rehypePlugins.push(
|
|
|
+ rehypeSanitizePlugin,
|
|
|
+ );
|
|
|
|
|
|
if (config.isEnabledXssPrevention) {
|
|
|
verifySanitizePlugin(options);
|