Skip to content

Commit

Permalink
Fix XSS vulnerability
Browse files Browse the repository at this point in the history
  • Loading branch information
davwheat committed Jun 6, 2021
1 parent eeb8fe1 commit 440bed8
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion js/src/common/Translator.ts → js/src/common/Translator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,23 @@ export default class Translator {
// future there should be a hook here to inspect the user and change the
// translation key. This will allow a gender property to determine which
// translation key is used.

if ('user' in parameters) {
const user = extract(parameters, 'user');

if (!parameters.username) parameters.username = username(user);
}
return parameters;

const escapedParameters: TranslatorParameters = {};

for (const param in parameters) {
const paramValue = parameters[param];

if (typeof paramValue === 'string') escapedParameters[param] = <>{parameters[param]}</>;
else escapedParameters[param] = parameters[param];
}

return escapedParameters;
}

trans(id: string, parameters: TranslatorParameters = {}) {
Expand Down

1 comment on commit 440bed8

@davwheat
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The details about this vulnerability have now been made public.

For more information, please see: https://discuss.flarum.org/d/27558-critical-security-update-to-flarum-core-v102

Please # to comment.