From be7a91f7bebfd9c0f1790ef136ea49c6062b5a0b Mon Sep 17 00:00:00 2001 From: Thomas Fussell Date: Sat, 6 Jul 2019 15:29:04 -0400 Subject: [PATCH] try default password on read failure, closes #161 --- source/workbook/workbook.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/source/workbook/workbook.cpp b/source/workbook/workbook.cpp index dae61446..6437996b 100644 --- a/source/workbook/workbook.cpp +++ b/source/workbook/workbook.cpp @@ -865,7 +865,23 @@ void workbook::load(std::istream &stream) { clear(); detail::xlsx_consumer consumer(*this); - consumer.read(stream); + + try + { + consumer.read(stream); + } + catch (xlnt::exception &e) + { + if (e.what() == std::string("xlnt::exception : encrypted xlsx, password required")) + { + stream.seekg(0, std::ios::beg); + consumer.read(stream, "VelvetSweatshop"); + } + else + { + throw; + } + } } void workbook::load(const std::vector &data)