changeset 5682:ccb335181571

avoid hardly recoverable crashes if #format specification is invalid
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Mon, 05 Apr 2010 13:42:21 +0200
parents 788131dd21c3
children cc754d368e13
files MoinMoin/Page.py MoinMoin/PageEditor.py
diffstat 2 files changed, 12 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/Page.py	Tue Mar 30 22:21:17 2010 +0200
+++ b/MoinMoin/Page.py	Mon Apr 05 13:42:21 2010 +0200
@@ -1262,7 +1262,10 @@
             self.getFormatterName() in self.cfg.caching_formats):
             # Everything is fine, now check the parser:
             if parser is None:
-                parser = wikiutil.searchAndImportPlugin(self.request.cfg, "parser", self.pi['format'])
+                try:
+                    parser = wikiutil.searchAndImportPlugin(self.request.cfg, "parser", self.pi['format'])
+                except wikiutil.PluginMissingError:
+                    return False
             return getattr(parser, 'caching', False)
         return False
 
@@ -1277,7 +1280,10 @@
         """
         request.clock.start('send_page_content')
         # Load the parser
-        Parser = wikiutil.searchAndImportPlugin(request.cfg, "parser", format)
+        try:
+            Parser = wikiutil.searchAndImportPlugin(request.cfg, "parser", format)
+        except wikiutil.PluginMissingError:
+            Parser = wikiutil.searchAndImportPlugin(request.cfg, "parser", "plain")
         parser = Parser(body, request, format_args=format_args, **kw)
 
         if not (do_cache and self.canUseCache(Parser)):
--- a/MoinMoin/PageEditor.py	Tue Mar 30 22:21:17 2010 +0200
+++ b/MoinMoin/PageEditor.py	Mon Apr 05 13:42:21 2010 +0200
@@ -484,7 +484,10 @@
 
         # QuickHelp originally by Georg Mischler <schorsch@lightingwiki.com>
         markup = self.pi['format'] or request.cfg.default_markup
-        parser = wikiutil.searchAndImportPlugin(self.request.cfg, "parser", markup)
+        try:
+            parser = wikiutil.searchAndImportPlugin(self.request.cfg, "parser", markup)
+        except wikiutil.PluginMissingError:
+            parser = wikiutil.searchAndImportPlugin(self.request.cfg, "parser", "plain")
         quickhelp = getattr(parser, 'quickhelp', None)
         if quickhelp:
             request.write(request.formatter.div(1, id="editor-help"))