changeset 3942:dd6938a4d07b

merged moin/1.7
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Fri, 15 Aug 2008 19:05:20 +0200
parents 28442c70f757 (current diff) b24e880f89bc (diff)
children 25d4db484bf1
files MoinMoin/auth/ldap_login.py docs/CHANGES
diffstat 5 files changed, 24 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/auth/ldap_login.py	Sun Aug 10 02:18:10 2008 +0200
+++ b/MoinMoin/auth/ldap_login.py	Fri Aug 15 19:05:20 2008 +0200
@@ -140,7 +140,7 @@
                         (ldap.OPT_X_TLS, self.start_tls),
                         #(ldap.OPT_X_TLS_ALLOW, 1),
                     ):
-                        if value:
+                        if value is not None:
                             ldap.set_option(option, value)
 
                 server = self.server_uri
--- a/MoinMoin/filter/__init__.py	Sun Aug 10 02:18:10 2008 +0200
+++ b/MoinMoin/filter/__init__.py	Fri Aug 15 19:05:20 2008 +0200
@@ -17,12 +17,27 @@
 
 standard_codings = ['utf-8', 'iso-8859-15', 'iso-8859-1', ]
 
+
+def quote_filename(filename):
+    """ quote a filename (could contain blanks or other special chars) in a
+        way suitable for the platform we run on.
+    """
+    # XXX Use os.name AND/OR sys.platform?
+    if os.name == 'posix':
+        filename = "'%s'" % filename
+    elif sys.platform == 'win32':
+        filename = '"%s"' % filename
+    else:
+        raise ValueError("MoinMoin.filter.quote_filename: os/platform not supported")
+    return filename
+
+
 def execfilter(cmd, filename, codings=standard_codings):
     """ use cmd to get plaintext content of filename
         to decode to unicode, we use the first coding of codings list that
         does not throw an exception or force ascii
     """
-    filter_cmd = cmd % filename
+    filter_cmd = cmd % quote_filename(filename)
     child_stdin, child_stdout, child_stderr = os.popen3(filter_cmd)
     data = child_stdout.read()
     errors = child_stderr.read()
--- a/MoinMoin/filter/application_msword.py	Sun Aug 10 02:18:10 2008 +0200
+++ b/MoinMoin/filter/application_msword.py	Fri Aug 15 19:05:20 2008 +0200
@@ -4,12 +4,15 @@
 
     Depends on: antiword command from antiword package
 
-    @copyright: 2006 MoinMoin:ThomasWaldmann
+    @copyright: 2006-2008 MoinMoin:ThomasWaldmann
     @license: GNU GPL, see COPYING for details.
 """
 
 from MoinMoin.filter import execfilter
 
 def execute(indexobj, filename):
-    return execfilter("HOME=/tmp antiword '%s'", filename) # no HOME makes antiword complain
+    cmd = "antiword %s"
+    if os.name == 'posix':
+        cmd = "HOME=/tmp " + cmd  # no HOME makes antiword complain (on Linux)
+    return execfilter(cmd, filename)
 
--- a/MoinMoin/filter/application_pdf.py	Sun Aug 10 02:18:10 2008 +0200
+++ b/MoinMoin/filter/application_pdf.py	Fri Aug 15 19:05:20 2008 +0200
@@ -11,5 +11,5 @@
 from MoinMoin.filter import execfilter
 
 def execute(indexobj, filename):
-    return execfilter("pdftotext -enc UTF-8 '%s' -", filename)
+    return execfilter("pdftotext -enc UTF-8 %s -", filename)
 
--- a/MoinMoin/filter/application_vnd_ms_excel.py	Sun Aug 10 02:18:10 2008 +0200
+++ b/MoinMoin/filter/application_vnd_ms_excel.py	Fri Aug 15 19:05:20 2008 +0200
@@ -11,7 +11,7 @@
 from MoinMoin.filter import execfilter
 
 def execute(indexobj, filename):
-    data = execfilter("xls2csv '%s'", filename)
+    data = execfilter("xls2csv %s", filename)
     # xls2csv uses comma as field separator and "field content",
     # we strip both to not confuse the indexer
     data = data.replace(u',', u' ').replace(u'"', u' ')