Package: python-docutils / 0.12+dfsg-1

odt-writer-ascii-filenames.diff Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
Description: Use only ASCII filenames in the ODF packages generated by the ODT writer
 The odf_odt writer embeds images in its output files and uses the
 original filenames as part of the embedded filenames.  Since the
 OpenDocument standard does not specify the filename charset, recode to
 ASCII (dropping non-representable characters) to be on the safe side.
 This patch also removes an invalid assumption about the encoding
 used internally by the interpreter, which has caused Debian bug
 #714317, and fixes #714313.
Author: Michael Schutte <michi@debian.org>
Bug-Debian: http://bugs.debian.org/714317
Bug-Debian: http://bugs.debian.org/714313
Forwarded: https://sourceforge.net/p/docutils/patches/113/
Last-Update: 2013-08-05

--- a/docutils/writers/odf_odt/__init__.py
+++ b/docutils/writers/odf_odt/__init__.py
@@ -595,8 +595,7 @@
                 continue
             try:
                 # encode/decode
-                destination1 = destination.decode('latin-1').encode('utf-8')
-                zfile.write(source, destination1)
+                zfile.write(source, destination)
             except OSError, e:
                 self.document.reporter.warning(
                     "Can't open file %s." % (source, ))
@@ -2076,7 +2075,8 @@
         else:
             self.image_count += 1
             filename = os.path.split(source)[1]
-            destination = 'Pictures/1%08x%s' % (self.image_count, filename, )
+            destination = 'Pictures/1%08x_%s' % (self.image_count,
+			    filename.encode("ascii", "ignore"))
             if source.startswith('http:'):
                 try:
                     imgfile = urllib2.urlopen(source)