[Python-modules-commits] [python-odf] 01/05: Import python-odf_1.3.4+dfsg.orig.tar.xz

Wolfgang Borgert debacle at moszumanska.debian.org
Sun Jan 22 12:08:40 UTC 2017


This is an automated email from the git hooks/post-receive script.

debacle pushed a commit to branch master
in repository python-odf.

commit c183b8b2ecc65e0886bb2766413c94e7b1275315
Author: W. Martin Borgert <debacle at debian.org>
Date:   Sun Jan 22 10:42:07 2017 +0000

    Import python-odf_1.3.4+dfsg.orig.tar.xz
---
 odf/namespaces.py                  |   2 +-
 odf/opendocument.py                |   5 +++--
 setup.py                           |   4 ++--
 tests/examples/externalcontent.txt |   1 +
 tests/examples/nasty.odt           | Bin 0 -> 1539 bytes
 tests/testload.py                  |  29 +++++++++++++++++------------
 6 files changed, 24 insertions(+), 17 deletions(-)

diff --git a/odf/namespaces.py b/odf/namespaces.py
index 2a779b4..3addef0 100644
--- a/odf/namespaces.py
+++ b/odf/namespaces.py
@@ -17,7 +17,7 @@
 #
 # Contributor(s):
 #
-__version__ = "1.3.3"
+__version__ = "1.3.4"
 
 TOOLSVERSION = u"ODFPY/" + __version__
 
diff --git a/odf/opendocument.py b/odf/opendocument.py
index ac81273..d2cf96f 100644
--- a/odf/opendocument.py
+++ b/odf/opendocument.py
@@ -674,7 +674,7 @@ class OpenDocument:
             zi = zipfile.ZipInfo(u"%ssettings.xml" % folder, self._now)
             zi.compress_type = zipfile.ZIP_DEFLATED
             zi.external_attr = UNIXPERMS
-            self._z.writestr(zi, anObject.settingsxml() )
+            self._z.writestr(zi, anObject.settingsxml().encode("utf-8") )
 
         # Write meta
         if self == anObject:
@@ -682,7 +682,7 @@ class OpenDocument:
             zi = zipfile.ZipInfo(u"meta.xml", self._now)
             zi.compress_type = zipfile.ZIP_DEFLATED
             zi.external_attr = UNIXPERMS
-            self._z.writestr(zi, anObject.metaxml() )
+            self._z.writestr(zi, anObject.metaxml().encode("utf-8") )
 
         # Write subobjects
         subobjectnum = 1
@@ -881,6 +881,7 @@ def __loadxmlparts(z, manifest, doc, objectpath):
 
             parser = make_parser()
             parser.setFeature(handler.feature_namespaces, 1)
+            parser.setFeature(handler.feature_external_ges, 0)
             parser.setContentHandler(LoadParser(doc))
             parser.setErrorHandler(handler.ErrorHandler())
 
diff --git a/setup.py b/setup.py
index 74878b0..dbd8b77 100644
--- a/setup.py
+++ b/setup.py
@@ -19,9 +19,9 @@
 #
 
 import platform
-from distutils.core import setup
+from setuptools import setup
 
-version = '1.3.3'
+version = '1.3.4'
 
 if platform.system() in ('Linux','Unix'):
     man1pages = [('share/man/man1', [
diff --git a/tests/examples/externalcontent.txt b/tests/examples/externalcontent.txt
new file mode 100644
index 0000000..84102df
--- /dev/null
+++ b/tests/examples/externalcontent.txt
@@ -0,0 +1 @@
+The quick brown fox jumps over the lazy dog
diff --git a/tests/examples/nasty.odt b/tests/examples/nasty.odt
new file mode 100644
index 0000000..9a1294e
Binary files /dev/null and b/tests/examples/nasty.odt differ
diff --git a/tests/testload.py b/tests/testload.py
index 063caa4..6eb2b60 100644
--- a/tests/testload.py
+++ b/tests/testload.py
@@ -88,9 +88,17 @@ class TestExampleDocs(unittest.TestCase):
         parastyles_odt = os.path.join(
             os.path.dirname(__file__), "examples", "parastyles.odt")
         d = load(parastyles_odt)
-        meta = unicode(d.metaxml(),'utf-8')
+        meta = d.metaxml()
         self.assertEqual(-1, meta.find(u"""<meta:generator>OpenOffice.org/2.3$Linux OpenOffice.org_project/680m6$Build-9226"""),"Must use the original generator string")
 
+    def test_metagenerator_odp(self):
+        """ Check that meta:generator is the original one """
+        parastyles_odt = os.path.join(
+            os.path.dirname(__file__), u"examples", u"emb_spreadsheet.odp")
+        d = load(parastyles_odt)
+        meta = d.metaxml()
+        self.assertNotEqual(-1, meta.find(u"""<meta:generator>ODFPY"""), "Must not use the original generator string")
+
 
     def test_simplelist(self):
         """ Check that lists are loaded correctly """
@@ -120,7 +128,7 @@ class TestExampleDocs(unittest.TestCase):
         simplelist_odt = os.path.join(
             os.path.dirname(__file__), "examples", "headerfooter.odt")
         d = load(simplelist_odt)
-        result = unicode(d.stylesxml(),'utf-8')
+        result = d.stylesxml()
         self.assertNotEqual(-1, result.find(u'''style:name="MP1"'''))
         self.assertNotEqual(-1, result.find(u'''style:name="MP2"'''))
         self.assertNotEqual(-1, result.find(u"""<style:header><text:p text:style-name="MP1">Header<text:tab/>"""))
@@ -145,16 +153,13 @@ class TestExampleDocs(unittest.TestCase):
         self.assertNotEqual(-1, result.find(u'''table:formula="=SQRT([.A1]*[.A1]+[.A2]*[.A2])"'''))
         self.assertNotEqual(-1, result.find(u'''table:formula="=SUM([.A1]:[.A2])"'''))
 
-class TestExampleDocs(unittest.TestCase):
-
-    def test_metagenerator(self):
-        """ Check that meta:generator is the original one """
-        parastyles_odt = os.path.join(
-            os.path.dirname(__file__), u"examples", u"emb_spreadsheet.odp")
-        d = load(parastyles_odt)
-        meta = d.metaxml()
-        self.assertNotEqual(-1, meta.find(u"""<meta:generator>ODFPY"""), "Must not use the original generator string")
-
+    def test_externalent(self):
+        """ Check that external entities are not loaded """
+        simplelist_odt = os.path.join(
+            os.path.dirname(__file__), "examples", "nasty.odt")
+        d = load(simplelist_odt)
+        result = unicode(d.contentxml(),'utf-8')
+        self.assertEquals(-1, result.find(u"""The quick brown fox jumps over the lazy dog"""))
 
     def test_spreadsheet(self):
         """ Load a document containing subobjects """

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-odf.git



More information about the Python-modules-commits mailing list