--- AttachFile.py	2010-06-08 22:50:15.000000000 +0800
+++ moin-1.9.2/MoinMoin/action/AttachFile.py	2010-02-28 23:28:45.000000000 +0800
@@ -161,7 +161,7 @@
         @return: complete path/filename of attached file
     """
     if isinstance(filename, unicode):
-        filename = wikiutil.quoteWikinameFS(filename)
+        filename = filename.encode(config.charset)
     return os.path.join(getAttachDir(request, pagename, create=1), filename)
 
 
@@ -211,11 +211,11 @@
         or an open file object (file content in e.g. a tempfile).
     """
     # replace illegal chars
-    target = wikiutil.quoteWikinameFS(wikiutil.taintfilename(target))
+    target = wikiutil.taintfilename(target)
 
     # get directory, and possibly create it
     attach_dir = getAttachDir(request, pagename, create=1)
-    fpath = os.path.join(attach_dir, target)
+    fpath = os.path.join(attach_dir, target).encode(config.charset)
 
     exists = os.path.exists(fpath)
     if exists:
@@ -249,7 +249,7 @@
     # get directory, do not create it
     attach_dir = getAttachDir(request, pagename, create=0)
     # remove file
-    fpath = os.path.join(attach_dir, wikiutil.quoteWikinameFS(target))
+    fpath = os.path.join(attach_dir, target).encode(config.charset)
     try:
         filesize = os.path.getsize(fpath)
         os.remove(fpath)
@@ -347,7 +347,7 @@
         html.append(fmt.bullet_list(1))
         for file in files:
             mt = wikiutil.MimeType(filename=file)
-            fullpath = os.path.join(attach_dir, wikiutil.quoteWikinameFS(file))
+            fullpath = os.path.join(attach_dir, file).encode(config.charset)
             st = os.stat(fullpath)
             base, ext = os.path.splitext(file)
             parmdict = {'file': wikiutil.escape(file),
@@ -423,7 +423,7 @@
 def _get_files(request, pagename):
     attach_dir = getAttachDir(request, pagename)
     if os.path.isdir(attach_dir):
-        files = [wikiutil.unquoteWikiname(fn)  for fn in os.listdir(attach_dir)]
+        files = [fn.decode(config.charset) for fn in os.listdir(attach_dir)]
         files.sort()
     else:
         files = []
@@ -588,10 +588,10 @@
         target, bytes = add_attachment(request, pagename, target, file_upload.stream, overwrite=overwrite)
         msg = _("Attachment '%(target)s' (remote name '%(filename)s')"
                 " with %(bytes)d bytes saved.") % {
-                'target': wikiutil.unquoteWikiname(target), 'filename': file_upload.filename, 'bytes': bytes}
+                'target': target, 'filename': file_upload.filename, 'bytes': bytes}
     except AttachmentAlreadyExists:
         msg = _("Attachment '%(target)s' (remote name '%(filename)s') already exists.") % {
-            'target': wikiutil.unquoteWikiname(target), 'filename': file_upload.filename}
+            'target': target, 'filename': file_upload.filename}
 
     # return attachment list
     upload_form(pagename, request, msg)
@@ -673,9 +673,9 @@
     newpage = Page(request, new_pagename)
     if newpage.exists(includeDeleted=1) and request.user.may.write(new_pagename) and request.user.may.delete(pagename):
         new_attachment_path = os.path.join(getAttachDir(request, new_pagename,
-                              create=1), wikiutil.quoteWikinameFS(new_attachment))
+                              create=1), new_attachment).encode(config.charset)
         attachment_path = os.path.join(getAttachDir(request, pagename),
-                          wikiutil.quoteWikinameFS(attachment))
+                          attachment).encode(config.charset)
 
         if os.path.exists(new_attachment_path):
             upload_form(pagename, request,
@@ -809,10 +809,7 @@
 
         # TODO: fix the encoding here, plain 8 bit is not allowed according to the RFCs
         # There is no solution that is compatible to IE except stripping non-ascii chars
-        if 'MSIE' in request.http_user_agent:
-            filename_enc = filename.encode('gbk')
-        else:
-            filename_enc = filename.encode(config.charset)
+        filename_enc = filename.encode(config.charset)
 
         # for dangerous files (like .html), when we are in danger of cross-site-scripting attacks,
         # we just let the user store them to disk ('attachment').
@@ -853,10 +850,7 @@
 
         # TODO: fix the encoding here, plain 8 bit is not allowed according to the RFCs
         # There is no solution that is compatible to IE except stripping non-ascii chars
-        if 'MSIE' in request.http_user_agent:
-            filename_enc = filename.encode('gbk')
-        else:
-            filename_enc = filename.encode(config.charset)
+        filename_enc = filename.encode(config.charset)
 
         # for dangerous files (like .html), when we are in danger of cross-site-scripting attacks,
         # we just let the user store them to disk ('attachment').
@@ -1162,7 +1156,7 @@
                 filepath = os.path.join(page_dir, filename)
                 data.addRow((
                     Page(request, pagename).link_to(request, querystr="action=AttachFile"),
-                    wikiutil.escape(wikiutil.unquoteWikiname(filename)),
+                    wikiutil.escape(filename.decode(config.charset)),
                     os.path.getsize(filepath),
                 ))
 
