Skip to content

Commit

Permalink
Potential fix for code scanning alert no. 26: DOM text reinterpreted …
Browse files Browse the repository at this point in the history
…as HTML (#8302)

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
  • Loading branch information
ardatan and github-advanced-security[bot] authored Jan 21, 2025
1 parent fabbcad commit d26ba2e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion website/src/components/examples-sandbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ export interface ExamplesSandboxProps extends React.HTMLAttributes<HTMLElement>
border?: boolean;
}

function isValidExampleDir(value: string): boolean {
return Object.values(EXAMPLES).some(group => Object.values(group).includes(value));
}

export function ExamplesSandbox({ lazy = false, border = false, ...rest }: ExamplesSandboxProps) {
const [exampleDir, setExampleDir] = useState('json-schema-example');
const [isVisible, setIsVisible] = useState(!lazy);
Expand Down Expand Up @@ -102,7 +106,10 @@ export function ExamplesSandbox({ lazy = false, border = false, ...rest }: Examp
<select
value={exampleDir}
onChange={e => {
setExampleDir(e.target.value);
const value = e.target.value;
if (isValidExampleDir(value)) {
setExampleDir(value);
}
}}
className="bg-inherit hive-focus w-[200px] cursor-pointer px-3 pr-8 p-2 border-beige-400 dark:border-neutral-800 border rounded-lg hover:bg-beige-100 dark:hover:bg-neutral-900 appearance-none"
>
Expand Down

0 comments on commit d26ba2e

Please sign in to comment.