Skip to content

Commit

Permalink
Merge pull request #7470 from kybin/kybin-patch-1
Browse files Browse the repository at this point in the history
UI: decode unicode properly in log page
  • Loading branch information
DingoEatingFuzz authored and Mahmood Ali committed Apr 9, 2020
1 parent 59c8245 commit c77749c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion ui/app/utils/stream-frames.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function decode(chunk) {
const frames = lines.map(line => JSON.parse(line)).filter(frame => frame.Data);

if (frames.length) {
frames.forEach(frame => (frame.Data = window.atob(frame.Data)));
frames.forEach(frame => (frame.Data = b64DecodeUnicode(frame.Data)));
return {
offset: frames[frames.length - 1].Offset,
message: frames.mapBy('Data').join(''),
Expand All @@ -24,3 +24,10 @@ export function decode(chunk) {

return {};
}

function b64DecodeUnicode(str) {
// from bytestream, to percent-encoding, to original string.
return decodeURIComponent(window.atob(str).split('').map(function(c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
}).join(''));
}

0 comments on commit c77749c

Please # to comment.