Files
codeql/javascript/ql/test/query-tests/Security/CWE-079/DomBasedXss/react-use-context.js
2025-02-28 13:27:28 +01:00

21 lines
438 B
JavaScript

import { useContext, Component } from 'react';
import { MyContext } from './react-create-context';
function useMyContext() {
return useContext(MyContext);
}
export function useDoc1() {
let { root } = useMyContext();
root.appendChild(window.name); // $ Alert
}
class C extends Component {
foo() {
let { root } = this.context;
root.appendChild(window.name); // $ Alert
}
}
C.contextType = MyContext;