summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAlex Marchant2024-04-05 18:45:58 +0200
committerjvoisin2024-04-05 18:45:58 +0200
commit156855ab7e79a311c1d19e9c937c41aed12b7506 (patch)
tree639c0d46875b05ed066e926c7e807a4fb66cca53 /tests
parent09672a2dccb2fea0035278c7014f319b85e89c31 (diff)
Remove dangling references from document.xml.rels
The file `word/_rels/document.xml.rels` is similar to `[Content_Types].xml` and has references to other files in the archive. If those references aren't removed Word refuses to open the document. # Please enter the commit message for your changes. Lines starting
Diffstat (limited to 'tests')
-rw-r--r--tests/test_libmat2.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/test_libmat2.py b/tests/test_libmat2.py
index 491f396..7855062 100644
--- a/tests/test_libmat2.py
+++ b/tests/test_libmat2.py
@@ -931,3 +931,24 @@ class TextDocx(unittest.TestCase):
931 931
932 os.remove('./tests/data/comment_clean.docx') 932 os.remove('./tests/data/comment_clean.docx')
933 os.remove('./tests/data/comment_clean.cleaned.docx') 933 os.remove('./tests/data/comment_clean.cleaned.docx')
934
935 def test_clean_document_xml_rels(self):
936 with zipfile.ZipFile('./tests/data/comment.docx') as zipin:
937 c = zipin.open('word/_rels/document.xml.rels')
938 content = c.read()
939 r = b'Target="comments.xml"'
940 self.assertIn(r, content)
941
942 shutil.copy('./tests/data/comment.docx', './tests/data/comment_clean.docx')
943 p = office.MSOfficeParser('./tests/data/comment_clean.docx')
944 self.assertTrue(p.remove_all())
945
946 with zipfile.ZipFile('./tests/data/comment_clean.cleaned.docx') as zipin:
947 c = zipin.open('word/_rels/document.xml.rels')
948 content = c.read()
949 r = b'Target="comments.xml"'
950 self.assertNotIn(r, content)
951
952 os.remove('./tests/data/comment_clean.docx')
953 os.remove('./tests/data/comment_clean.cleaned.docx')
954