Skip to content

Commit

Permalink
Merge pull request #461 from ONLYOFFICE/feature/convert-to
Browse files Browse the repository at this point in the history
Feature/convert to
  • Loading branch information
konovalovsergey authored Mar 14, 2024
2 parents 6511a99 + 4490016 commit 5f785de
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions DocService/sources/converterservice.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,24 @@ function convertTo(req, res) {
if (req.params.format) {
format = req.params.format;
}
//todo https://github.com/LibreOffice/core/blob/9d3366f5b392418dc83bc0adbe3d215cff4b3605/desktop/source/lib/init.cxx#L3478
let password = req.body['Password'];
if (password) {
if (password.length > constants.PASSWORD_MAX_LENGTH) {
ctx.logger.warn('convert-to Password too long actual = %s; max = %s', password.length, constants.PASSWORD_MAX_LENGTH);
res.sendStatus(400);
return;
}
}
//by analogy with Password
let passwordToOpen = req.body['PasswordToOpen'];
if (passwordToOpen) {
if (passwordToOpen.length > constants.PASSWORD_MAX_LENGTH) {
ctx.logger.warn('convert-to PasswordToOpen too long actual = %s; max = %s', passwordToOpen.length, constants.PASSWORD_MAX_LENGTH);
res.sendStatus(400);
return;
}
}
let pdfVer = req.body['PDFVer'];
if (pdfVer && pdfVer.startsWith("PDF/A") && 'pdf' === format) {
format = 'pdfa';
Expand All @@ -486,9 +504,6 @@ function convertTo(req, res) {
res.sendStatus(400);
return;
}
//todo https://github.com/CollaboraOnline/online/blob/master/wsd/COOLWSD.cpp
//req.body['options']

let docId, fileTo, status, originalname;
if (req.file && req.file.originalname && req.file.buffer) {
originalname = req.file.originalname;
Expand Down Expand Up @@ -532,6 +547,14 @@ function convertTo(req, res) {
"scale": 100
}}));
}
if (password) {
let encryptedPassword = yield utils.encryptPassword(ctx, password);
cmd.setSavePassword(encryptedPassword);
}
if (passwordToOpen) {
let encryptedPassword = yield utils.encryptPassword(ctx, passwordToOpen);
cmd.setPassword(encryptedPassword);
}

fileTo = constants.OUTPUT_NAME;
let outputExt = formatChecker.getStringFromFormat(outputFormat);
Expand Down

0 comments on commit 5f785de

Please sign in to comment.