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

fix: Fix XSS vulnerability #2

Merged
merged 1 commit into from Feb 25, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
fix: Fix XSS vulnerability
  • Loading branch information
bcldvd committed Feb 25, 2022
commit 133606ffaec2edd9918d9fba5771ed21da7876a5
8 changes: 8 additions & 0 deletions src/helpers/string-encoder.helper.ts
@@ -0,0 +1,8 @@
export function stringEncode(string: string) {
let encodedString = '';
for (let i = 0; i < string.length; i++) {
let charCodePointHex = string.charCodeAt(i).toString(16);
encodedString += `\\u${charCodePointHex}`;
}
return encodedString;
}
2 changes: 2 additions & 0 deletions src/ssr-pages.builder.ts
Expand Up @@ -3,6 +3,7 @@ import * as handlebars from 'handlebars';
import { join } from 'path';
import background from './helpers/background.helper';
import inlineSVG from './helpers/inlineSVG.helper';
import { stringEncode } from './helpers/string-encoder.helper';
import { MessagePageOptions } from './ssr-pages.interface';

export class SSRPages {
Expand All @@ -25,6 +26,7 @@ export class SSRPages {
}

build(msgPageOpts: MessagePageOptions) {
msgPageOpts.redirect.link = stringEncode(msgPageOpts.redirect.link);
return this.templateMessagePage(msgPageOpts);
}
}