@mintlify/common 1.0.1300 → 1.0.1302
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.
- package/dist/mdx/getMDXOptions.js +2 -0
- package/dist/mdx/plugins/remark/index.d.ts +1 -0
- package/dist/mdx/plugins/remark/index.js +1 -0
- package/dist/mdx/plugins/remark/remarkMdxRemoveUnsafeSmil.d.ts +7 -0
- package/dist/mdx/plugins/remark/remarkMdxRemoveUnsafeSmil.js +35 -0
- package/dist/mdx/utils.d.ts +1 -0
- package/dist/mdx/utils.js +8 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -5,6 +5,7 @@ import { remarkMdxExpandExpressions, } from './plugins/remark/remarkMdxExpandExp
|
|
|
5
5
|
import { remarkMdxPageStyles } from './plugins/remark/remarkMdxPageStyles.js';
|
|
6
6
|
import { remarkMdxDetectJs } from './plugins/remark/remarkMdxRemoveJs.js';
|
|
7
7
|
import { remarkMdxRemoveUnknownJsx } from './plugins/remark/remarkMdxRemoveUnknownJsx/index.js';
|
|
8
|
+
import { remarkMdxRemoveUnsafeSmil } from './plugins/remark/remarkMdxRemoveUnsafeSmil.js';
|
|
8
9
|
import { remarkMermaid } from './plugins/remark/remarkMermaid.js';
|
|
9
10
|
import { remarkNoCopyLanguage } from './plugins/remark/remarkNoCopyLanguage.js';
|
|
10
11
|
import { remarkParseTitleMarkdown, remarkRenderTitleMarkdown, } from './plugins/remark/remarkTitleMarkdown.js';
|
|
@@ -70,6 +71,7 @@ export const getMDXOptions = ({ data, remarkPlugins = [], earlyRemarkPlugins = [
|
|
|
70
71
|
...remarkPlugins,
|
|
71
72
|
remarkRenderTitleMarkdown,
|
|
72
73
|
remarkMapExplicitAnchors,
|
|
74
|
+
remarkMdxRemoveUnsafeSmil,
|
|
73
75
|
[
|
|
74
76
|
remarkMdxRemoveUnknownJsx,
|
|
75
77
|
{ allowlist: ['style', ...allowedComponents, ...knownComponents] },
|
|
@@ -6,6 +6,7 @@ export * from './remarkRemoveImports.js';
|
|
|
6
6
|
export * from './remarkExtractTableOfContents.js';
|
|
7
7
|
export * from './remarkMdxRemoveUnusedVariables.js';
|
|
8
8
|
export * from './remarkMdxRemoveUnknownJsx/index.js';
|
|
9
|
+
export * from './remarkMdxRemoveUnsafeSmil.js';
|
|
9
10
|
export * from './remarkMdxExpandExpressions.js';
|
|
10
11
|
export * from './remarkMdxClientComponentBoundaries.js';
|
|
11
12
|
export * from './remarkMermaid.js';
|
|
@@ -6,6 +6,7 @@ export * from './remarkRemoveImports.js';
|
|
|
6
6
|
export * from './remarkExtractTableOfContents.js';
|
|
7
7
|
export * from './remarkMdxRemoveUnusedVariables.js';
|
|
8
8
|
export * from './remarkMdxRemoveUnknownJsx/index.js';
|
|
9
|
+
export * from './remarkMdxRemoveUnsafeSmil.js';
|
|
9
10
|
export * from './remarkMdxExpandExpressions.js';
|
|
10
11
|
export * from './remarkMdxClientComponentBoundaries.js';
|
|
11
12
|
export * from './remarkMermaid.js';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Root } from 'mdast';
|
|
2
|
+
import type { MdxJsxFlowElement, MdxJsxTextElement } from 'mdast-util-mdx-jsx';
|
|
3
|
+
type JsxElement = MdxJsxFlowElement | MdxJsxTextElement;
|
|
4
|
+
type SmilCandidate = Partial<Pick<JsxElement, 'name' | 'attributes'>>;
|
|
5
|
+
export declare const isUnsafeSmilElement: ({ name, attributes }: SmilCandidate) => boolean;
|
|
6
|
+
export declare const remarkMdxRemoveUnsafeSmil: () => (tree: Root) => void;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { remove } from 'unist-util-remove';
|
|
2
|
+
import { isMdxJsxElement, SMIL_ELEMENT_NAMES } from '../../utils.js';
|
|
3
|
+
const SMIL_ELEMENTS = new Set(SMIL_ELEMENT_NAMES.map((name) => name.toLowerCase()));
|
|
4
|
+
const ANIMATION_VALUE_ATTRIBUTES = new Set(['values', 'from', 'to', 'by']);
|
|
5
|
+
const REFERENCE_ATTRIBUTES = new Set(['href', 'xlink:href', 'xlinkhref']);
|
|
6
|
+
const SCRIPTABLE_TARGETS = new Set(['href', 'xlinkhref', 'src', 'style']);
|
|
7
|
+
const SCRIPTABLE_URL = /(?:javascript|vbscript|data):/;
|
|
8
|
+
const normalize = (value) => Array.from(value)
|
|
9
|
+
.filter((character) => character > ' ')
|
|
10
|
+
.join('')
|
|
11
|
+
.toLowerCase();
|
|
12
|
+
const localName = (name) => name.slice(name.lastIndexOf(':') + 1).toLowerCase();
|
|
13
|
+
const targetsScriptableAttribute = (attributeName) => {
|
|
14
|
+
const name = localName(attributeName);
|
|
15
|
+
return SCRIPTABLE_TARGETS.has(name) || name.startsWith('on');
|
|
16
|
+
};
|
|
17
|
+
function isSafeSmilAttribute(attribute) {
|
|
18
|
+
if (attribute.type === 'mdxJsxExpressionAttribute')
|
|
19
|
+
return false;
|
|
20
|
+
const name = attribute.name.toLowerCase();
|
|
21
|
+
if (name.startsWith('on'))
|
|
22
|
+
return false;
|
|
23
|
+
if (typeof attribute.value !== 'string')
|
|
24
|
+
return attribute.value == null;
|
|
25
|
+
const value = normalize(attribute.value);
|
|
26
|
+
if (name === 'attributename')
|
|
27
|
+
return !targetsScriptableAttribute(value);
|
|
28
|
+
if (REFERENCE_ATTRIBUTES.has(name))
|
|
29
|
+
return value.startsWith('#');
|
|
30
|
+
return !ANIMATION_VALUE_ATTRIBUTES.has(name) || !SCRIPTABLE_URL.test(value);
|
|
31
|
+
}
|
|
32
|
+
export const isUnsafeSmilElement = ({ name, attributes = [] }) => name != null && SMIL_ELEMENTS.has(localName(name)) && !attributes.every(isSafeSmilAttribute);
|
|
33
|
+
export const remarkMdxRemoveUnsafeSmil = () => (tree) => {
|
|
34
|
+
remove(tree, { cascade: false }, (node) => isMdxJsxElement(node) && isUnsafeSmilElement(node));
|
|
35
|
+
};
|
package/dist/mdx/utils.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { MdxFlowExpression, MdxjsEsm, MdxJsxAttribute, MdxJsxExpressionAttribute
|
|
|
3
3
|
import type { MdxJsxFlowElement, MdxJsxTextElement } from 'mdast-util-mdx-jsx';
|
|
4
4
|
import type { Node } from 'unist';
|
|
5
5
|
import type { MdxNodeBodyChildType } from '../types/mdx/index.js';
|
|
6
|
+
export declare const SMIL_ELEMENT_NAMES: readonly ["animate", "animateMotion", "animateTransform", "mpath", "set"];
|
|
6
7
|
export declare const isMdxJsEsm: (node: Node) => node is MdxjsEsm;
|
|
7
8
|
export declare const isMdxExpression: (node: Node) => node is MdxFlowExpression | MdxTextExpression;
|
|
8
9
|
export declare function estreeIsProgram<T extends MdxFlowExpression | MdxTextExpression | MdxjsEsm>(node: T): node is T & {
|
package/dist/mdx/utils.js
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
export const SMIL_ELEMENT_NAMES = [
|
|
2
|
+
'animate',
|
|
3
|
+
'animateMotion',
|
|
4
|
+
'animateTransform',
|
|
5
|
+
'mpath',
|
|
6
|
+
'set',
|
|
7
|
+
];
|
|
1
8
|
export const isMdxJsEsm = (node) => node.type === 'mdxjsEsm';
|
|
2
9
|
export const isMdxExpression = (node) => node.type === 'mdxFlowExpression' || node.type === 'mdxTextExpression';
|
|
3
10
|
export function estreeIsProgram(node) {
|
|
@@ -142,6 +149,7 @@ export const allowedComponents = [
|
|
|
142
149
|
'sup',
|
|
143
150
|
'u',
|
|
144
151
|
'svg',
|
|
152
|
+
...SMIL_ELEMENT_NAMES,
|
|
145
153
|
'table',
|
|
146
154
|
'tbody',
|
|
147
155
|
'td',
|