mirror of
https://github.com/searxng/searxng.git
synced 2026-08-20 06:01:24 +00:00
[fix] calculator: XSS from innerHTML (#6551)
* [fix] calculator: XSS from innerHTML * [build] /static
This commit is contained in:
@@ -80,7 +80,12 @@ export default class Calculator extends Plugin {
|
||||
|
||||
try {
|
||||
const node = Calculator.math.parse(searchInput.value);
|
||||
return `${node.toString()} = ${node.evaluate()}`;
|
||||
const value = node.evaluate();
|
||||
if (typeof value !== "number") {
|
||||
return;
|
||||
}
|
||||
|
||||
return `${node.toString()} = ${value}`;
|
||||
} catch {
|
||||
// not a compatible math expression
|
||||
return;
|
||||
|
||||
@@ -23,7 +23,7 @@ export const appendAnswerElement = (element: HTMLElement | string | number): voi
|
||||
|
||||
if (!(element instanceof HTMLElement)) {
|
||||
const span = document.createElement("span");
|
||||
span.innerHTML = element.toString();
|
||||
span.textContent = element.toString();
|
||||
// biome-ignore lint/style/noParameterAssign: TODO
|
||||
element = span;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user