From 88aad76a0e54b4a8757bbc9ea45fec8f70baa832 Mon Sep 17 00:00:00 2001 From: James Moger Date: Fri, 5 Oct 2012 08:16:11 -0400 Subject: [PATCH] Catch all exceptions from MarkdownPapers and rethrow as ParseException (issue 142) --- docs/04_releases.mkd | 1 + src/com/gitblit/utils/MarkdownUtils.java | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/docs/04_releases.mkd b/docs/04_releases.mkd index ffd56ddc..55bdfd71 100644 --- a/docs/04_releases.mkd +++ b/docs/04_releases.mkd @@ -11,6 +11,7 @@ If you are updating from an earlier release AND you have indexed branches with t #### fixes +- Wrapped Markdown parser with improved exception handler (issue 142) - Fixed duplicate entries in repository cache (issue 140) - Fixed connection leak in LDAPUserService (issue 139) - Fixed bug in commit page where changes to a submodule threw a null pointer exception (issue 132) diff --git a/src/com/gitblit/utils/MarkdownUtils.java b/src/com/gitblit/utils/MarkdownUtils.java index 828225db..0b8c9c57 100644 --- a/src/com/gitblit/utils/MarkdownUtils.java +++ b/src/com/gitblit/utils/MarkdownUtils.java @@ -67,9 +67,15 @@ public class MarkdownUtils { Markdown md = new Markdown(); md.transform(markdownReader, writer); return writer.toString().trim(); + } catch (StringIndexOutOfBoundsException e) { + LoggerFactory.getLogger(MarkdownUtils.class).error("MarkdownPapers failed to parse Markdown!", e); + throw new java.text.ParseException(e.getMessage(), 0); } catch (ParseException p) { LoggerFactory.getLogger(MarkdownUtils.class).error("MarkdownPapers failed to parse Markdown!", p); throw new java.text.ParseException(p.getMessage(), 0); + } catch (Exception e) { + LoggerFactory.getLogger(MarkdownUtils.class).error("MarkdownPapers failed to parse Markdown!", e); + throw new java.text.ParseException(e.getMessage(), 0); } finally { try { writer.close(); -- 2.39.5