summaryrefslogtreecommitdiff
path: root/writerperfect/qa/unit
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2017-09-08 12:02:51 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2017-09-08 14:10:16 +0200
commita27eb931c22313d4dd5c73b35358c0532d20b79e (patch)
treeeb922abdafe8c26d7f6a3302aadcde90c49f143a /writerperfect/qa/unit
parent9c34c9c2409a8f09c3373d314ef7872d7c2aee92 (diff)
EPUB export: fix double escaped NBSP
The EPUB package interface already XML-escapes characters, avoid a double escape. And once that works, handle NBSP/tabs. Change-Id: I8b7bbdc2592096bdd46fbdb29b48b723ef5cf990 Reviewed-on: https://gerrit.libreoffice.org/42098 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'writerperfect/qa/unit')
-rw-r--r--writerperfect/qa/unit/EPUBExportTest.cxx15
-rw-r--r--writerperfect/qa/unit/data/writer/epubexport/escape.fodt16
2 files changed, 31 insertions, 0 deletions
diff --git a/writerperfect/qa/unit/EPUBExportTest.cxx b/writerperfect/qa/unit/EPUBExportTest.cxx
index 0d869737fc8e..10fd5eb5a94a 100644
--- a/writerperfect/qa/unit/EPUBExportTest.cxx
+++ b/writerperfect/qa/unit/EPUBExportTest.cxx
@@ -63,6 +63,7 @@ public:
void testNamedStyleInheritance();
void testNestedSpan();
void testLineBreak();
+ void testEscape();
CPPUNIT_TEST_SUITE(EPUBExportTest);
CPPUNIT_TEST(testOutlineLevel);
@@ -77,6 +78,7 @@ public:
CPPUNIT_TEST(testNamedStyleInheritance);
CPPUNIT_TEST(testNestedSpan);
CPPUNIT_TEST(testLineBreak);
+ CPPUNIT_TEST(testEscape);
CPPUNIT_TEST_SUITE_END();
};
@@ -330,6 +332,19 @@ void EPUBExportTest::testLineBreak()
assertXPath(mpXmlDoc, "//xhtml:p[2]/xhtml:br", 1);
}
+void EPUBExportTest::testEscape()
+{
+ createDoc("escape.fodt", {});
+
+ mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml");
+ // This was lost.
+ assertXPathContent(mpXmlDoc, "//xhtml:p[1]/xhtml:span[1]", OUString::fromUtf8("\xc2\xa0"));
+ // Make sure escaping happens only once.
+ assertXPathContent(mpXmlDoc, "//xhtml:p[1]/xhtml:span[2]", "a&b");
+ // This was also lost.
+ assertXPathContent(mpXmlDoc, "//xhtml:p[1]/xhtml:span[3]", "\t");
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(EPUBExportTest);
}
diff --git a/writerperfect/qa/unit/data/writer/epubexport/escape.fodt b/writerperfect/qa/unit/data/writer/epubexport/escape.fodt
new file mode 100644
index 000000000000..8d23fb36ef1d
--- /dev/null
+++ b/writerperfect/qa/unit/data/writer/epubexport/escape.fodt
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:officeooo="http://openoffice.org/2009/office" office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.text">
+ <office:automatic-styles>
+ <style:style style:name="T1" style:family="text">
+ <style:text-properties officeooo:rsid="0006b966"/>
+ </style:style>
+ <style:style style:name="T2" style:family="text">
+ <style:text-properties fo:font-weight="bold" officeooo:rsid="0006b966" style:font-weight-asian="bold" style:font-weight-complex="bold"/>
+ </style:style>
+ </office:automatic-styles>
+ <office:body>
+ <office:text>
+ <text:p><text:s/><text:span text:style-name="T1">a&amp;b</text:span><text:span text:style-name="T2"><text:tab/></text:span></text:p>
+ </office:text>
+ </office:body>
+</office:document>