🔒️ Fix tiptap url CVE (#1459)
This commit is contained in:
@@ -5,12 +5,12 @@ import { IconEdit, IconEditOff } from '@tabler/icons-react';
|
|||||||
import { BubbleMenu, useEditor } from '@tiptap/react';
|
import { BubbleMenu, useEditor } from '@tiptap/react';
|
||||||
import StarterKit from '@tiptap/starter-kit';
|
import StarterKit from '@tiptap/starter-kit';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
|
import { useEditModeStore } from '~/components/Dashboard/Views/useEditModeStore';
|
||||||
|
import { useConfigContext } from '~/config/provider';
|
||||||
import { useConfigStore } from '~/config/store';
|
import { useConfigStore } from '~/config/store';
|
||||||
import { useColorTheme } from '~/tools/color';
|
import { useColorTheme } from '~/tools/color';
|
||||||
import { api } from '~/utils/api';
|
import { api } from '~/utils/api';
|
||||||
|
|
||||||
import { useEditModeStore } from '~/components/Dashboard/Views/useEditModeStore';
|
|
||||||
import { useConfigContext } from '~/config/provider';
|
|
||||||
import { WidgetLoading } from '../loading';
|
import { WidgetLoading } from '../loading';
|
||||||
import { INotebookWidget } from './NotebookWidgetTile';
|
import { INotebookWidget } from './NotebookWidgetTile';
|
||||||
|
|
||||||
@@ -33,7 +33,14 @@ export function Editor({ widget }: { widget: INotebookWidget }) {
|
|||||||
const [debouncedContent] = useDebouncedValue(content, 500);
|
const [debouncedContent] = useDebouncedValue(content, 500);
|
||||||
|
|
||||||
const editor = useEditor({
|
const editor = useEditor({
|
||||||
extensions: [StarterKit, Link],
|
extensions: [
|
||||||
|
StarterKit,
|
||||||
|
Link.configure({
|
||||||
|
validate(url) {
|
||||||
|
return /^https?:\/\//.test(url);
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
],
|
||||||
content,
|
content,
|
||||||
editable: false,
|
editable: false,
|
||||||
onUpdate: (e) => {
|
onUpdate: (e) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user