Raise an exception if no EBX_HANDLER is found in PDF

This commit is contained in:
Grégory Soutadé 2021-09-28 15:01:04 +02:00
parent dc15fc7197
commit 33ea9e7d65
2 changed files with 10 additions and 2 deletions

View File

@ -68,6 +68,7 @@ namespace gourou
enum DOWNLOAD_ERROR { enum DOWNLOAD_ERROR {
DW_NO_ITEM = 0x1200, DW_NO_ITEM = 0x1200,
DW_NO_EBX_HANDLER,
}; };
enum SIGNIN_ERROR { enum SIGNIN_ERROR {

View File

@ -611,6 +611,7 @@ namespace gourou
else if (res == PDF) else if (res == PDF)
{ {
uPDFParser::Parser parser; uPDFParser::Parser parser;
bool EBXHandlerFound = false;
try try
{ {
@ -631,6 +632,7 @@ namespace gourou
// Update EBX_HANDLER with rights // Update EBX_HANDLER with rights
if ((*it)->hasKey("Filter") && (**it)["Filter"]->str() == "/EBX_HANDLER") if ((*it)->hasKey("Filter") && (**it)["Filter"]->str() == "/EBX_HANDLER")
{ {
EBXHandlerFound = true;
uPDFParser::Object* ebx = (*it)->clone(); uPDFParser::Object* ebx = (*it)->clone();
(*ebx)["ADEPT_ID"] = new uPDFParser::String(item->getResource()); (*ebx)["ADEPT_ID"] = new uPDFParser::String(item->getResource());
(*ebx)["EBX_BOOKID"] = new uPDFParser::String(item->getResource()); (*ebx)["EBX_BOOKID"] = new uPDFParser::String(item->getResource());
@ -642,7 +644,12 @@ namespace gourou
} }
} }
if (EBXHandlerFound)
parser.write(path, true); parser.write(path, true);
else
{
EXCEPTION(DW_NO_EBX_HANDLER, "EBX_HANDLER not found");
}
} }
return res; return res;