Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check params to prevent cross site scripting #1848

Merged
merged 4 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions mod/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,19 @@ module.exports = async function view(req, res) {
// The default_view is assumed without an implicit template value.
params.template ??= 'default_view';

params.dir ??= xyzEnv.DIR;
params.dir = xyzEnv.DIR;

params.login ??= (xyzEnv.PRIVATE || xyzEnv.PUBLIC) && 'true';
params.login = (xyzEnv.PRIVATE || xyzEnv.PUBLIC) && 'true';

params.title ??= xyzEnv.TITLE;
params.title = xyzEnv.TITLE;

params.language ??= req.params.user?.language || 'en';
params.language ??= req.params.user?.language;

// Test ISO629 language param.
if (!/^[a-z]{2}$/.test(params.language)) {
// Assign English as default language.
params.language = 'en';
}

const template = await languageTemplates(params);

Expand Down
11 changes: 3 additions & 8 deletions public/views/login/_login_en.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@
</head>

<body class="login_form">
<div class="language-selector">
Choose Language:
<div class="language-selector">Choose Language:
<select
id="language"
onChange="(function(e){location=e.target.value})(event)"
>
onChange="(function(e){location=e.target.value})(event)">
<option value="{{dir}}?language=en&login=true">English</option>
<option value="{{dir}}?language=de&login=true">Deutsch</option>
<option value="{{dir}}?language=fr&login=true">Français</option>
Expand All @@ -33,7 +31,6 @@

<form action="{{dir}}/api/user/login" method="post" autocomplete="off">
<input style="display: none" name="language" required value="en" />
<input style="display: none" name="redirect" value="{{redirect}}" />

<div class="input-group">
<input
Expand Down Expand Up @@ -70,9 +67,7 @@
to log in.
</p>

<a class="switch" href="{{dir}}/api/user/register?register=true"
>Register a new account or reset your password.</a
>
<a class="switch" href="{{dir}}/api/user/register?register=true">Register a new account or reset your password.</a>
</form>
</body>
</html>