From 80e2c82249bc5192ed1497716840edda9b97051e Mon Sep 17 00:00:00 2001 From: reger Date: Thu, 24 Dec 2015 02:00:45 +0100 Subject: [PATCH] fix NPE on empty blog importfile parameter --- htroot/Blog.html | 18 +++++++++--------- htroot/BlogComments.html | 12 ++++++------ source/net/yacy/data/BlogBoard.java | 23 ++++++++++++----------- 3 files changed, 27 insertions(+), 26 deletions(-) diff --git a/htroot/Blog.html b/htroot/Blog.html index 39af1537a..baae0ff90 100644 --- a/htroot/Blog.html +++ b/htroot/Blog.html @@ -77,9 +77,9 @@ - - - + + + :: @@ -121,9 +121,9 @@ - - - + + + :: @@ -138,10 +138,10 @@
- +
- +
:: @@ -157,7 +157,7 @@
- +
#(/mode)# diff --git a/htroot/BlogComments.html b/htroot/BlogComments.html index c78933870..42b8d1e4d 100644 --- a/htroot/BlogComments.html +++ b/htroot/BlogComments.html @@ -70,9 +70,9 @@ - - - + + + #(/allow)# @@ -109,9 +109,9 @@ - - - + + + diff --git a/source/net/yacy/data/BlogBoard.java b/source/net/yacy/data/BlogBoard.java index f97f7c794..9b28dc1b9 100644 --- a/source/net/yacy/data/BlogBoard.java +++ b/source/net/yacy/data/BlogBoard.java @@ -159,18 +159,19 @@ public class BlogBoard { } public boolean importXML(final String input) { - final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - try { - final DocumentBuilder builder = factory.newDocumentBuilder(); - return parseXMLimport(builder.parse(new ByteArrayInputStream(UTF8.getBytes(input)))); - } catch (final ParserConfigurationException ex) { - ConcurrentLog.logException(ex); - } catch (final SAXException ex) { - ConcurrentLog.logException(ex); - } catch (final IOException ex) { - ConcurrentLog.logException(ex); + if (input != null && !input.isEmpty()) { + final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + try { + final DocumentBuilder builder = factory.newDocumentBuilder(); + return parseXMLimport(builder.parse(new ByteArrayInputStream(UTF8.getBytes(input)))); + } catch (final ParserConfigurationException ex) { + ConcurrentLog.logException(ex); + } catch (final SAXException ex) { + ConcurrentLog.logException(ex); + } catch (final IOException ex) { + ConcurrentLog.logException(ex); + } } - return false; }