I am using the GMail API to retrieve messages. The messages are machine generated, so follow a similar format.
Although most of the messages are fine, I am getting a DOMException using atob to decode the message body for a subset of the messages.
I think I've narrowed it down to messages that have a section in it that looks like:
--------------------- Sudo (secure-log) Begin ------------------------
jeremy => root
--------------
/usr/bin/docker - 5 Time(s).
---------------------- Sudo (secure-log) End -------------------------
Specifically I think that the problem happens because of the =>
.
The error is:
Error parsing DOMException: Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.
Code fragment:
gapi.client.gmail.users.threads.get({
userId: 'me',
id: thread.id
})
.then(function(response){
var
content,
message = response.result.messages[0],
rawContent = message.payload.body.data;
try{
content = atob(rawContent);
}