Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0f9a0e8

Browse files
committed
Revert escaping for i18n strings
Looks like the library already escapes, so we were getting double escaping.
1 parent 4029c1e commit 0f9a0e8

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

src/node/routes/login.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const getRoot = async (req: Request, error?: Error): Promise<string> => {
3131
const locale = req.args["locale"] || "en"
3232
i18n.changeLanguage(locale)
3333
const appName = req.args["app-name"] || "code-server"
34-
const welcomeText = escapeHtml(req.args["welcome-text"] || (i18n.t("WELCOME", { app: appName }) as string))
34+
const welcomeText = req.args["welcome-text"] || (i18n.t("WELCOME", { app: appName }) as string)
3535

3636
// Determine password message using i18n
3737
let passwordMsg = i18n.t("LOGIN_PASSWORD", { configFile: req.args.config })
@@ -40,23 +40,16 @@ const getRoot = async (req: Request, error?: Error): Promise<string> => {
4040
} else if (req.args.usingEnvHashedPassword) {
4141
passwordMsg = i18n.t("LOGIN_USING_HASHED_PASSWORD")
4242
}
43-
passwordMsg = escapeHtml(passwordMsg)
44-
45-
// Get messages from i18n (with HTML escaping for security)
46-
const loginTitle = escapeHtml(i18n.t("LOGIN_TITLE", { app: appName }))
47-
const loginBelow = escapeHtml(i18n.t("LOGIN_BELOW"))
48-
const passwordPlaceholder = escapeHtml(i18n.t("PASSWORD_PLACEHOLDER"))
49-
const submitText = escapeHtml(i18n.t("SUBMIT"))
5043

5144
return replaceTemplates(
5245
req,
5346
content
54-
.replace(/{{I18N_LOGIN_TITLE}}/g, loginTitle)
47+
.replace(/{{I18N_LOGIN_TITLE}}/g, i18n.t("LOGIN_TITLE", { app: appName }))
5548
.replace(/{{WELCOME_TEXT}}/g, welcomeText)
5649
.replace(/{{PASSWORD_MSG}}/g, passwordMsg)
57-
.replace(/{{I18N_LOGIN_BELOW}}/g, loginBelow)
58-
.replace(/{{I18N_PASSWORD_PLACEHOLDER}}/g, passwordPlaceholder)
59-
.replace(/{{I18N_SUBMIT}}/g, submitText)
50+
.replace(/{{I18N_LOGIN_BELOW}}/g, i18n.t("LOGIN_BELOW"))
51+
.replace(/{{I18N_PASSWORD_PLACEHOLDER}}/g, i18n.t("PASSWORD_PLACEHOLDER"))
52+
.replace(/{{I18N_SUBMIT}}/g, i18n.t("SUBMIT"))
6053
.replace(/{{ERROR}}/, error ? `<div class="error">${escapeHtml(error.message)}</div>` : ""),
6154
)
6255
}

0 commit comments

Comments
 (0)