mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
Don't use btoa/atob as they are problematic with non ascii char sets
This commit is contained in:
parent
32cc24d75b
commit
0fc5f034a4
17
gui/sock.js
17
gui/sock.js
|
@ -370,7 +370,8 @@ client.on('data', function(socketdata) {
|
||||||
|
|
||||||
socketLog.info(data)
|
socketLog.info(data)
|
||||||
// we need to encode here to do a deep check for checking if file or message
|
// we need to encode here to do a deep check for checking if file or message
|
||||||
var encoded_data = atob(data['data'])
|
//var encoded_data = atob(data['data'])
|
||||||
|
var encoded_data = Buffer.from(data['data'],'base64').toString('utf-8');
|
||||||
var splitted_data = encoded_data.split(split_char)
|
var splitted_data = encoded_data.split(split_char)
|
||||||
|
|
||||||
if(splitted_data[0] == 'f'){
|
if(splitted_data[0] == 'f'){
|
||||||
|
@ -423,7 +424,8 @@ client.on('data', function(socketdata) {
|
||||||
for (i = 0; i < data['data-array'].length; i++) {
|
for (i = 0; i < data['data-array'].length; i++) {
|
||||||
try{
|
try{
|
||||||
// we need to encode here to do a deep check for checking if file or message
|
// we need to encode here to do a deep check for checking if file or message
|
||||||
var encoded_data = atob(data['data-array'][i]['data'])
|
//var encoded_data = atob(data['data-array'][i]['data'])
|
||||||
|
var encoded_data = Buffer.from(data['data-array'][i]['data'],'base64').toString('utf-8');
|
||||||
var splitted_data = encoded_data.split(split_char)
|
var splitted_data = encoded_data.split(split_char)
|
||||||
|
|
||||||
|
|
||||||
|
@ -519,8 +521,11 @@ exports.sendFile = function(dxcallsign, mode, frames, filename, filetype, data,
|
||||||
|
|
||||||
data = datatype + split_char + filename + split_char + filetype + split_char + checksum + split_char + data
|
data = datatype + split_char + filename + split_char + filetype + split_char + checksum + split_char + data
|
||||||
socketLog.info(data)
|
socketLog.info(data)
|
||||||
socketLog.info(btoa(data))
|
//socketLog.info(btoa(data))
|
||||||
data = btoa(data)
|
//Btoa / atob will not work with charsets > 8 bits (i.e. the emojis); should probably move away from using it
|
||||||
|
//TODO: Will need to update anyother occurences and throughly test
|
||||||
|
//data = btoa(data)
|
||||||
|
data = Buffer.from(data,'utf-8').toString("base64");
|
||||||
|
|
||||||
command = '{"type" : "arq", "command" : "send_raw", "parameter" : [{"dxcallsign" : "' + dxcallsign + '", "mode" : "' + mode + '", "n_frames" : "' + frames + '", "data" : "' + data + '"}]}'
|
command = '{"type" : "arq", "command" : "send_raw", "parameter" : [{"dxcallsign" : "' + dxcallsign + '", "mode" : "' + mode + '", "n_frames" : "' + frames + '", "data" : "' + data + '"}]}'
|
||||||
writeTncCommand(command)
|
writeTncCommand(command)
|
||||||
|
@ -544,8 +549,8 @@ exports.sendMessage = function(dxcallsign, mode, frames, data, checksum, uuid, c
|
||||||
|
|
||||||
console.log("CHECKSUM" + checksum)
|
console.log("CHECKSUM" + checksum)
|
||||||
//socketLog.info(btoa(data))
|
//socketLog.info(btoa(data))
|
||||||
data = btoa(data)
|
//data = btoa(data)
|
||||||
|
data = Buffer.from(data,'utf-8').toString("base64");
|
||||||
|
|
||||||
//command = '{"type" : "arq", "command" : "send_message", "parameter" : [{ "dxcallsign" : "' + dxcallsign + '", "mode" : "' + mode + '", "n_frames" : "' + frames + '", "data" : "' + data + '" , "checksum" : "' + checksum + '"}]}'
|
//command = '{"type" : "arq", "command" : "send_message", "parameter" : [{ "dxcallsign" : "' + dxcallsign + '", "mode" : "' + mode + '", "n_frames" : "' + frames + '", "data" : "' + data + '" , "checksum" : "' + checksum + '"}]}'
|
||||||
command = '{"type" : "arq", "command" : "send_raw", "uuid" : "'+ uuid +'", "parameter" : [{"dxcallsign" : "' + dxcallsign + '", "mode" : "' + mode + '", "n_frames" : "' + frames + '", "data" : "' + data + '", "attempts": "15"}]}'
|
command = '{"type" : "arq", "command" : "send_raw", "uuid" : "'+ uuid +'", "parameter" : [{"dxcallsign" : "' + dxcallsign + '", "mode" : "' + mode + '", "n_frames" : "' + frames + '", "data" : "' + data + '", "attempts": "15"}]}'
|
||||||
|
|
Loading…
Reference in a new issue