changeset 3945:3a6be2089de9

Merge with backed out changeset.
author Alexander Schremmer <alex AT alexanderweb DOT de>
date Fri, 15 Aug 2008 23:20:31 +0200
parents a86a245db9cb (current diff) 25d4db484bf1 (diff)
children 54fffaea4e22
files
diffstat 6 files changed, 26 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/_tests/test_sourcecode.py	Fri Aug 15 23:20:11 2008 +0200
+++ b/MoinMoin/_tests/test_sourcecode.py	Fri Aug 15 23:20:31 2008 +0200
@@ -32,6 +32,8 @@
 
 try:
     import xattr
+    if not hasattr(xattr, "xattr"): # there seem to be multiple modules with that name
+        raise ImportError
     def mark_file_ok(path, mtime):
         x = xattr.xattr(path)
         try:
--- a/MoinMoin/auth/ldap_login.py	Fri Aug 15 23:20:11 2008 +0200
+++ b/MoinMoin/auth/ldap_login.py	Fri Aug 15 23:20:31 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	Fri Aug 15 23:20:11 2008 +0200
+++ b/MoinMoin/filter/__init__.py	Fri Aug 15 23:20:31 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	Fri Aug 15 23:20:11 2008 +0200
+++ b/MoinMoin/filter/application_msword.py	Fri Aug 15 23:20:31 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	Fri Aug 15 23:20:11 2008 +0200
+++ b/MoinMoin/filter/application_pdf.py	Fri Aug 15 23:20:31 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	Fri Aug 15 23:20:11 2008 +0200
+++ b/MoinMoin/filter/application_vnd_ms_excel.py	Fri Aug 15 23:20:31 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' ')