Merge pull request #137 from QURIresearch/fix-xss

Fix XSS issue with Squiggle Editor
This commit is contained in:
Sam Nolan 2022-03-30 21:48:28 +11:00 committed by GitHub
commit 550a8a0cb1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 5 deletions

View File

@ -25,11 +25,7 @@ export interface SquiggleEditorProps {
onEnvChange?(env: exportEnv): void;
}
const highlight = (editor: HTMLInputElement) => {
let code = editor.textContent;
code = code.replace(/\((\w+?)(\b)/g, '(<font color="#8a2be2">$1</font>$2');
editor.innerHTML = code;
};
const highlight = (_: HTMLInputElement) => {};
interface SquiggleEditorState {
expression: string;

View File

@ -0,0 +1,22 @@
import { SquiggleEditor } from "../SquiggleEditor";
import { Canvas, Meta, Story, Props } from "@storybook/addon-docs";
<Meta title="Squiggle/SquiggleEditor" component={SquiggleEditor} />
export const Template = (props) => <SquiggleEditor {...props} />;
# Squiggle Editor
Squiggle Editor is a Squiggle chart with a text editor included for changing
the distribution.
<Canvas>
<Story
name="Normal"
args={{
initialSquiggleString: "normal(5,2)",
}}
>
{Template.bind({})}
</Story>
</Canvas>