changeset 6004:2061aa0dff6d

fix crash when macro names contain non-ascii chars
author Cheer Xiao <xiaqqaix@gmail.com>
date Sat, 30 Nov 2013 21:31:52 +0800
parents 575660fc7a5a
children 9a9ad16c62fb
files MoinMoin/macro/__init__.py
diffstat 1 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/macro/__init__.py	Sun Nov 24 02:27:09 2013 +0100
+++ b/MoinMoin/macro/__init__.py	Sat Nov 30 21:31:52 2013 +0800
@@ -101,6 +101,13 @@
         """
         self.name = macro_name
         try:
+            str(macro_name)
+        except UnicodeEncodeError:
+            _ = self._
+            return self.formatter.text(_('<<%(macro_name)s: invalid macro name>>') % {
+                   'macro_name': macro_name,
+                 })
+        try:
             call = wikiutil.importPlugin(self.cfg, 'macro', macro_name,
                                          function='macro_%s' % macro_name)
             execute = lambda _self, _args: wikiutil.invoke_extension_function(