[Libreoffice-commits] core.git: sw/qa writerfilter/source
Thorsten Behrens
Thorsten.Behrens at CIB.de
Tue Jun 16 00:25:39 PDT 2015
sw/qa/extras/rtfimport/data/bin-skipping.rtf | 19 +++++++++++++++++++
sw/qa/extras/rtfimport/rtfimport.cxx | 6 ++++++
writerfilter/source/rtftok/rtftokenizer.cxx | 6 ++++++
3 files changed, 31 insertions(+)
New commits:
commit 63fbd90099098218994899ca7da3eb5e1656e4e7
Author: Thorsten Behrens <Thorsten.Behrens at CIB.de>
Date: Wed Jun 10 08:49:13 2015 +0200
rtf: skip binary data also in skip-group mode
Since there might be arbitrary rtf markup inside, we rather
shouldn't act upon.
Change-Id: Ia782d89cb4ce8f34df64a3e0cba16de2db7b7ccf
Reviewed-on: https://gerrit.libreoffice.org/16206
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
diff --git a/sw/qa/extras/rtfimport/data/bin-skipping.rtf b/sw/qa/extras/rtfimport/data/bin-skipping.rtf
new file mode 100644
index 0000000..4426074
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/bin-skipping.rtf
@@ -0,0 +1,19 @@
+{\rtf1\ansi\deff3\adeflang1025
+{\fonttbl{\f0\froman\fprq2\fcharset0 Times New Roman;}{\f1\froman\fprq2\fcharset2 Symbol;}{\f2\fswiss\fprq2\fcharset0 Arial;}{\f3\froman\fprq2\fcharset0 Liberation Serif{\*\falt Times New Roman};}{\f4\fswiss\fprq2\fcharset0 Liberation Sans{\*\falt Arial};}{\f5\fnil\fprq2\fcharset0 SimSun;}{\f6\fnil\fprq2\fcharset0 Droid Sans Devanagari;}{\f7\fswiss\fprq0\fcharset128 Droid Sans Devanagari;}}
+{\colortbl;\red0\green0\blue0;\red128\green128\blue128;}
+{\stylesheet{\s0\snext0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af5\langfe2052\dbch\af6\afs24\alang1081\loch\f3\fs24\lang1033 Normal;}
+{\s15\sbasedon0\snext16\sb240\sa120\keepn\dbch\af5\dbch\af6\afs28\loch\f4\fs28 Heading;}
+{\s16\sbasedon0\snext16\sl288\slmult1\sb0\sa140 Text Body;}
+{\s17\sbasedon16\snext17\sl288\slmult1\sb0\sa140\dbch\af7 List;}
+{\s18\sbasedon0\snext18\sb120\sa120\noline\i\dbch\af7\afs24\ai\fs24 Caption;}
+{\s19\sbasedon0\snext19\noline\dbch\af7 Index;}
+}
+\deftab709
+\viewscale100
+{\*\pgdsctbl
+{\pgdsc0\pgdscuse451\pgwsxn12240\pghsxn15840\marglsxn1134\margrsxn1134\margtsxn1134\margbsxn1134\pgdscnxt0 Default Style;}}
+{\*\shprslt\bin24 }{\par MUST NOT IMPORT}}}
+\formshade\paperh15840\paperw12240\margl1134\margr1134\margt1134\margb1134\sectd\sbknone\sectunlocked1\pgndec\pgwsxn12240\pghsxn15840\marglsxn1134\margrsxn1134\margtsxn1134\margbsxn1134\ftnbj\ftnstart1\ftnrstcont\ftnnar\aenddoc\aftnrstcont\aftnstart1\aftnnrlc
+{\*\ftnsep\chftnsep}\pgndec\pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af5\langfe2052\dbch\af6\afs24\alang1081\loch\f3\fs24\lang1033{\rtlch \ltrch\loch
+text}
+\par }
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 86dddfc..8171b6d 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -2301,6 +2301,12 @@ DECLARE_RTFIMPORT_TEST(testTdf90315, "tdf90315.rtf")
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1270), getProperty<sal_Int32>(xTextSection->getPropertyValue("TextColumns"), "AutomaticDistance"));
}
+DECLARE_RTFIMPORT_TEST(testBinSkipping, "bin-skipping.rtf")
+{
+ // before, it was importing '/nMUST NOT IMPORT'
+ CPPUNIT_ASSERT_EQUAL(OUString("text"), getRun(getParagraph(1), 1)->getString());
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/rtftok/rtftokenizer.cxx b/writerfilter/source/rtftok/rtftokenizer.cxx
index 416c6bb..1a920c6 100644
--- a/writerfilter/source/rtftok/rtftokenizer.cxx
+++ b/writerfilter/source/rtftok/rtftokenizer.cxx
@@ -282,7 +282,13 @@ bool RTFTokenizer::lookupMathKeyword(RTFMathSymbol& rSymbol)
RTFError RTFTokenizer::dispatchKeyword(OString& rKeyword, bool bParam, int nParam)
{
if (m_rImport.getDestination() == Destination::SKIP)
+ {
+ // skip binary data explicitely, to not trip over rtf markup
+ // control characters
+ if (rKeyword.equals("bin"))
+ Strm().SeekRel(nParam);
return RTFError::OK;
+ }
SAL_INFO("writerfilter.rtf", OSL_THIS_FUNC << ": keyword '\\" << rKeyword.getStr() <<
"' with param? " << (bParam ? 1 : 0) <<" param val: '" << (bParam ? nParam : 0) << "'");
RTFSymbol aSymbol;
More information about the Libreoffice-commits
mailing list