Skip to content

Commit 22a22a8

Browse files
committed
fix: escape error.message on login failure
1 parent c505fc4 commit 22a22a8

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/node/routes/login.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const getRoot = async (req: Request, error?: Error): Promise<string> => {
4141
req,
4242
content
4343
.replace(/{{PASSWORD_MSG}}/g, passwordMsg)
44-
.replace(/{{ERROR}}/, error ? `<div class="error">${error.message}</div>` : ""),
44+
.replace(/{{ERROR}}/, error ? `<div class="error">${escapeHtml(error.message)}</div>` : ""),
4545
)
4646
}
4747

@@ -112,8 +112,7 @@ router.post("/", async (req, res) => {
112112

113113
throw new Error("Incorrect password")
114114
} catch (error) {
115-
const html = await getRoot(req, error)
116-
const escapedHtml = escapeHtml(html)
117-
res.send(escapedHtml)
115+
const htmlToRender = await getRoot(req, error)
116+
res.send(htmlToRender)
118117
}
119118
})

0 commit comments

Comments
 (0)