Skip to content

Commit 7fc1f6a

Browse files
use better mechanism for base64 decoding with unicode characters (microsoft#172445)
Fixes microsoft#172441
1 parent 88e4667 commit 7fc1f6a

File tree

1 file changed

+6
-2
lines changed
  • extensions/microsoft-authentication/src/browser

1 file changed

+6
-2
lines changed

extensions/microsoft-authentication/src/browser/buffer.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ export function base64Encode(text: string): string {
88
}
99

1010
export function base64Decode(text: string): string {
11-
const data = atob(text);
12-
return data;
11+
// modification of https://stackoverflow.com/a/38552302
12+
const replacedCharacters = text.replace(/-/g, '+').replace(/_/g, '/');
13+
const decodedText = decodeURIComponent(atob(replacedCharacters).split('').map(function (c) {
14+
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
15+
}).join(''));
16+
return decodedText;
1317
}

0 commit comments

Comments
 (0)