fix: web: add form's typeahead now shows non-ascii text correctly (#1961)

(Fix contributed by Arsen Arsenović)
This commit is contained in:
Simon Michael 2022-12-16 09:38:52 -10:00
parent 331b419c97
commit ae87b1efd5
2 changed files with 13 additions and 1 deletions

View File

@ -190,7 +190,8 @@ toBloodhoundJson ts =
"]"
]
where
b64wrap = ("atob(\""<>) . (<>"\")") . encodeBase64
-- decodeBase64EncodedText is defined in add-form.hamlet
b64wrap = ("decodeBase64EncodedText(\""<>) . (<>"\")") . encodeBase64
zipDefault :: a -> [a] -> [a] -> [(a, a)]
zipDefault def (b:bs) (c:cs) = (b, c):(zipDefault def bs cs)

View File

@ -19,6 +19,17 @@
jQuery('input[name=description]').typeahead({ highlight: true }, { source: descriptionsSuggester.ttAdapter() });
jQuery('input[name=account]').typeahead({ highlight: true }, { source: accountsSuggester.ttAdapter() });
});
const utf8textdecoder = new TextDecoder();
function decodeBase64EncodedText(b64) {
const unb64 = window.atob(b64);
const arr = new Uint8Array(unb64.length);
for (let i = 0; i < arr.length; i++) {
arr[i] = unb64.charCodeAt(i);
}
return utf8textdecoder.decode(arr);
}
^{extra}
<div .row>