diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2017-08-23 09:09:57 +0300 |
---|---|---|
committer | Aron Budea <aron.budea@collabora.com> | 2017-11-22 16:27:11 +0100 |
commit | f3af5926f93f46e96caa6b85e08723f150c94463 (patch) | |
tree | 347e600db3cfd28e4317539876c29b061d675bb7 /sw | |
parent | 3c01d0ff65342432055dcb575601f3b3f446e8bd (diff) |
tdf#111964: only trim XML whitespace
OUString::trim() uses rtl_uString_newTrim, which relies upon
rtl_ImplIsWhitespace. The latter treats as whitespaces not only
characters with values less than or equal to 32, but also Unicode
General Punctuation area Space and some Control characters. Thus,
using OUString::trim() is incorrect when the goal is to trim XML
whitespace, which is defined as one of 0x09, 0x0A, 0x0D, 0x20.
The comments for OUString::trim() and rtl_uString_newTrim are
corrected to describe which characters are considered whitespace.
A unit test included.
Change-Id: I45a132be923a52dcd5a4c35aeecb53d423b49fec
Reviewed-on: https://gerrit.libreoffice.org/41444
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Mike Kaganski <mike.kaganski@collabora.com>
(cherry picked from commit 5b518ab051cc04e672ceb01da42b06625a1a4ce9)
Reviewed-on: https://gerrit.libreoffice.org/44758
Reviewed-by: Aron Budea <aron.budea@collabora.com>
Tested-by: Aron Budea <aron.budea@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/tdf111964.docx | bin | 0 -> 1481 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport9.cxx | 10 |
2 files changed, 10 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf111964.docx b/sw/qa/extras/ooxmlexport/data/tdf111964.docx Binary files differnew file mode 100644 index 000000000000..7cb85a1d87df --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/tdf111964.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx index b2c8a417109c..8c1537ffc268 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx @@ -384,6 +384,16 @@ DECLARE_OOXMLEXPORT_TEST(testTdf107684, "tdf107684.odt") assertXPath(pXmlDoc, "//w:style[@w:styleId='Heading1']/w:pPr/w:outlineLvl", 1); } +DECLARE_OOXMLEXPORT_TEST(testTdf111964, "tdf111964.docx") +{ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + // Unicode spaces that are not XML whitespace must not be trimmed + const sal_Unicode sWSReference [] { 0x2002, 0x2002, 0x2002, 0x2002, 0x2002, 0 }; + assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:r[4]/w:t", sWSReference); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |