Kaydet (Commit) 474178ac authored tarafından Caolán McNamara's avatar Caolán McNamara

ofz#3174 disallow header in header

Change-Id: I509fbfe5d7c319f0515896ecfca4183113eef764
Reviewed-on: https://gerrit.libreoffice.org/41635Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 32e07ada
......@@ -229,6 +229,7 @@ std::unique_ptr<HBox> HWPPara::readHBox(HWPFile & hwpf)
hbox.reset(new Hidden);
break;
case CH_HEADER_FOOTER: // 16
if (!hwpf.already_importing_type(CH_HEADER_FOOTER))
hbox.reset(new HeaderFooter);
break;
case CH_FOOTNOTE: // 17
......@@ -274,11 +275,19 @@ std::unique_ptr<HBox> HWPPara::readHBox(HWPFile & hwpf)
break;
}
}
if (!hbox || !hbox->Read(hwpf))
if (!hbox)
return nullptr;
hwpf.push_hpara_type(scflag);
bool bRead = hbox->Read(hwpf);
hwpf.pop_hpara_type();
if (!bRead)
{
hbox.reset();
return hbox;
return nullptr;
}
if( hh == CH_TEXT_BOX || hh == CH_PICTURE || hh == CH_LINE )
{
FBox *fbox = static_cast<FBox *>(hbox.get());
......
......@@ -25,6 +25,7 @@
#ifndef INCLUDED_HWPFILTER_SOURCE_HWPFILE_H
#define INCLUDED_HWPFILTER_SOURCE_HWPFILE_H
#include <algorithm>
#include <list>
#include <vector>
#include <stdio.h>
......@@ -252,6 +253,13 @@ class DLLEXPORT HWPFile
int getMaxSettedPage(){ return m_nMaxSettedPage; }
void setMaxSettedPage(){ m_nMaxSettedPage = m_nCurrentPage; }
void push_hpara_type(unsigned char scflag) { element_import_stack.push_back(scflag); }
bool already_importing_type(unsigned char scflag) const
{
return std::find(element_import_stack.begin(), element_import_stack.end(), scflag) != element_import_stack.end();
}
void pop_hpara_type() { element_import_stack.pop_back(); }
private:
int compareCharShape(CharShape const *shape);
int compareParaShape(ParaShape const *shape);
......@@ -290,6 +298,8 @@ class DLLEXPORT HWPFile
std::vector<HeaderFooter*> headerfooters;
std::vector<ShowPageNum*> pagenumbers;
std::vector<Table*> tables;
//track the stack of HParas types we're currently importing
std::vector<unsigned char> element_import_stack;
// for global document handling
static HWPFile *cur_doc;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment