Skip to content

Commit

Permalink
[bug] Fix 'savefromorigin' with password; Fix bug 70466
Browse files Browse the repository at this point in the history
  • Loading branch information
konovalovsergey committed Oct 2, 2024
1 parent eb2077c commit fcf1195
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 28 deletions.
53 changes: 26 additions & 27 deletions DocService/sources/DocsCoServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1553,35 +1553,34 @@ exports.getExternalChangeInfo = getExternalChangeInfo;
exports.checkJwt = checkJwt;
exports.getRequestParams = getRequestParams;
exports.checkJwtHeader = checkJwtHeader;
function encryptPasswordParams(ctx, data) {
return co(function*(){
let dataWithPassword;
if (data.type === 'openDocument' && data.message) {
dataWithPassword = data.message;
} else if (data.type === 'auth' && data.openCmd) {
dataWithPassword = data.openCmd;
} else if (data.c === 'savefromorigin') {
dataWithPassword = data;
}
if (dataWithPassword && dataWithPassword.password) {
if (dataWithPassword.password.length > constants.PASSWORD_MAX_LENGTH) {
//todo send back error
ctx.logger.warn('encryptPasswordParams password too long actual = %s; max = %s', dataWithPassword.password.length, constants.PASSWORD_MAX_LENGTH);
dataWithPassword.password = null;
} else {
dataWithPassword.password = yield utils.encryptPassword(ctx, dataWithPassword.password);
}

async function encryptPasswordParams(ctx, data) {
let dataWithPassword;
if (data.type === 'openDocument' && data.message) {
dataWithPassword = data.message;
} else if (data.type === 'auth' && data.openCmd) {
dataWithPassword = data.openCmd;
} else if (data.c === 'savefromorigin') {
dataWithPassword = data;
}
if (dataWithPassword && dataWithPassword.password) {
if (dataWithPassword.password.length > constants.PASSWORD_MAX_LENGTH) {
//todo send back error
ctx.logger.warn('encryptPasswordParams password too long actual = %s; max = %s', dataWithPassword.password.length, constants.PASSWORD_MAX_LENGTH);
dataWithPassword.password = null;
} else {
dataWithPassword.password = await utils.encryptPassword(ctx, dataWithPassword.password);
}
if (dataWithPassword && dataWithPassword.savepassword) {
if (dataWithPassword.savepassword.length > constants.PASSWORD_MAX_LENGTH) {
//todo send back error
ctx.logger.warn('encryptPasswordParams password too long actual = %s; max = %s', dataWithPassword.savepassword.length, constants.PASSWORD_MAX_LENGTH);
dataWithPassword.savepassword = null;
} else {
dataWithPassword.savepassword = yield utils.encryptPassword(ctx, dataWithPassword.savepassword);
}
}
if (dataWithPassword && dataWithPassword.savepassword) {
if (dataWithPassword.savepassword.length > constants.PASSWORD_MAX_LENGTH) {
//todo send back error
ctx.logger.warn('encryptPasswordParams password too long actual = %s; max = %s', dataWithPassword.savepassword.length, constants.PASSWORD_MAX_LENGTH);
dataWithPassword.savepassword = null;
} else {
dataWithPassword.savepassword = await utils.encryptPassword(ctx, dataWithPassword.savepassword);
}
});
}
}
exports.encryptPasswordParams = encryptPasswordParams;
exports.getOpenFormatByEditor = getOpenFormatByEditor;
Expand Down
2 changes: 1 addition & 1 deletion DocService/sources/canvasservice.js
Original file line number Diff line number Diff line change
Expand Up @@ -1449,7 +1449,7 @@ exports.downloadAs = function(req, res) {
yield* commandSave(ctx, cmd, outputData);
break;
case 'savefromorigin':
docsCoServer.encryptPasswordParams(ctx, cmd)
yield docsCoServer.encryptPasswordParams(ctx, cmd);
yield* commandSaveFromOrigin(ctx, cmd, outputData, row && row.password);
break;
case 'sendmm':
Expand Down

0 comments on commit fcf1195

Please sign in to comment.