1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-24 07:49:41 +02:00

fix: atob convert unicode in config failed (#3415)

atob only support decode ascii char, when this unicode in config, it will show unknown char.
This commit is contained in:
Iceyer 2019-12-10 00:52:02 +08:00 committed by xAt0mZ
parent e9f6861df0
commit 58c00401e9

View file

@ -1,5 +1,11 @@
import { ResourceControlViewModel } from 'Portainer/models/resourceControl/resourceControl';
function b64DecodeUnicode(str) {
return decodeURIComponent(atob(str).split('').map(function(c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
}).join(''));
}
export function ConfigViewModel(data) {
this.Id = data.ID;
this.CreatedAt = data.CreatedAt;
@ -7,7 +13,7 @@ export function ConfigViewModel(data) {
this.Version = data.Version.Index;
this.Name = data.Spec.Name;
this.Labels = data.Spec.Labels;
this.Data = atob(data.Spec.Data);
this.Data = b64DecodeUnicode(data.Spec.Data);
if (data.Portainer && data.Portainer.ResourceControl) {
this.ResourceControl = new ResourceControlViewModel(data.Portainer.ResourceControl);