js: fix file_name return on decrypt

--
* src/gpgmejs: Line 228 checked the wrong variable. To avoid further
  confusion, _result was renamed to returnValue in the whole file
This commit is contained in:
Maximilian Krambach 2018-08-27 11:21:02 +02:00
parent 08cd34afb7
commit 557fec6002

View File

@ -217,28 +217,28 @@ export class GpgME {
putData(msg, data); putData(msg, data);
return new Promise(function (resolve, reject){ return new Promise(function (resolve, reject){
msg.post().then(function (result){ msg.post().then(function (result){
let _result = { data: result.data }; let returnValue = { data: result.data };
_result.format = result.format ? result.format : null; returnValue.format = result.format ? result.format : null;
if (result.hasOwnProperty('dec_info')){ if (result.hasOwnProperty('dec_info')){
_result.is_mime = result.dec_info.is_mime ? true: false; returnValue.is_mime = result.dec_info.is_mime ? true: false;
if (result.dec_info.file_name) { if (result.dec_info.file_name) {
_result.file_name = result.dec_info.file_name; returnValue.file_name = result.dec_info.file_name;
} }
} }
if (!result.file_name) { if (!returnValue.file_name) {
_result.file_name = null; returnValue.file_name = null;
} }
if (result.hasOwnProperty('info') if (result.hasOwnProperty('info')
&& result.info.hasOwnProperty('signatures') && result.info.hasOwnProperty('signatures')
&& Array.isArray(result.info.signatures) && Array.isArray(result.info.signatures)
) { ) {
_result.signatures = collectSignatures( returnValue.signatures = collectSignatures(
result.info.signatures); result.info.signatures);
} }
if (_result.signatures instanceof Error){ if (returnValue.signatures instanceof Error){
reject(_result.signatures); reject(returnValue.signatures);
} else { } else {
resolve(_result); resolve(returnValue);
} }
}, function (error){ }, function (error){
reject(error); reject(error);
@ -330,18 +330,18 @@ export class GpgME {
if (!message.info || !message.info.signatures){ if (!message.info || !message.info.signatures){
reject(gpgme_error('SIG_NO_SIGS')); reject(gpgme_error('SIG_NO_SIGS'));
} else { } else {
let _result = { let returnValue = {
signatures: collectSignatures(message.info.signatures) signatures: collectSignatures(message.info.signatures)
}; };
if (_result.signatures instanceof Error){ if (returnValue.signatures instanceof Error){
reject(_result.signatures); reject(returnValue.signatures);
} else { } else {
_result.is_mime = message.info.is_mime? true: false; returnValue.is_mime = message.info.is_mime? true: false;
if (message.info.filename){ if (message.info.filename){
_result.file_name = message.info.filename; returnValue.file_name = message.info.filename;
} }
_result.data = message.data; returnValue.data = message.data;
resolve(_result); resolve(returnValue);
} }
} }
}, function (error){ }, function (error){