Skip to content

Commit ad96925

Browse files
committed
codeQL fix
1 parent a80ff51 commit ad96925

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/components/pmf-game/LevelScene.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,14 @@ function MaxWisdom({ wisdom, animation = 'random' }: { wisdom: string; animation
236236
const [hasStartedTyping, setHasStartedTyping] = React.useState(false)
237237
const plainText = React.useMemo(() => {
238238
// Strip HTML tags for character counting
239-
// Use regex for SSR compatibility (document doesn't exist on server)
240-
return wisdom.replace(/<[^>]*>/g, '')
239+
// Use iterative replacement to handle nested/malformed tags (for CodeQL security)
240+
let text = wisdom
241+
let previous = ''
242+
while (text !== previous) {
243+
previous = text
244+
text = text.replace(/<[^>]*>/g, '')
245+
}
246+
return text
241247
}, [wisdom])
242248

243249
React.useEffect(() => {

0 commit comments

Comments
 (0)