Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
andiwand committed Aug 18, 2024
1 parent 98423dc commit 1a0aae1
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions cli/src/translate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,25 @@ int main(int argc, char **argv) {
password = argv[3];
}

File file{input};
DecodedFile decoded_file{input};

HtmlConfig config;
config.editable = true;

PasswordCallback password_callback = [&]() {
if (!password) {
if (decoded_file.is_document_file()) {
DocumentFile document_file = decoded_file.document_file();
if (document_file.password_encrypted() && !password) {
std::cerr << "document encrypted but no password given" << std::endl;
std::exit(2);
return 2;
}
if (document_file.password_encrypted() &&
!document_file.decrypt(*password)) {
std::cerr << "wrong password" << std::endl;
return 1;
}
return *password;
};

try {
html::translate(file, output, config, password_callback);
} catch (const WrongPassword &e) {
std::cerr << "wrong password" << std::endl;
return 1;
}

HtmlConfig config;
config.editable = true;

html::translate(decoded_file, output, config);

return 0;
}

0 comments on commit 1a0aae1

Please sign in to comment.