fix NPE on empty blog importfile parameter

pull/37/head
reger 9 years ago
parent 8a8e53b1a1
commit 80e2c82249

@ -77,9 +77,9 @@
</dd> </dd>
</dl> </dl>
<input type="hidden" name="page" value="#[pageid]#" /> <input type="hidden" name="page" value="#[pageid]#" />
<input type="submit" name="submit" value="Submit" /> <input type="submit" name="submit" class="btn btn-primary" value="Submit" />
<input type="submit" name="preview" value="Preview" /> <input type="submit" name="preview" class="btn btn-default" value="Preview" />
<input type="submit" name="discard" value="Discard" /> <input type="submit" name="discard" class="btn btn-danger" value="Discard" />
</fieldset> </fieldset>
</form> </form>
:: ::
@ -121,9 +121,9 @@
</dd> </dd>
</dl> </dl>
<input type="hidden" name="page" value="#[pageid]#" /> <input type="hidden" name="page" value="#[pageid]#" />
<input type="submit" name="submit" value="Submit" /> <input type="submit" name="submit" class="btn btn-primary" value="Submit" />
<input type="submit" name="preview" value="Preview" /> <input type="submit" name="preview" class="btn btn-default" value="Preview" />
<input type="submit" name="discard" value="Discard" /> <input type="submit" name="discard" class="btn btn-danger" value="Discard" />
</fieldset> </fieldset>
</form> </form>
:: ::
@ -138,10 +138,10 @@
<form action="Blog.html" method="post" enctype="multipart/form-data" accept-charset="UTF-8"> <form action="Blog.html" method="post" enctype="multipart/form-data" accept-charset="UTF-8">
<input type="hidden" name="delete" value="sure" /> <input type="hidden" name="delete" value="sure" />
<input type="hidden" name="page" value="#[pageid]#" /> <input type="hidden" name="page" value="#[pageid]#" />
<input type="submit" value="Yes, delete it." /> <input type="submit" class="btn btn-danger" value="Yes, delete it." />
</form> </form>
<form action="Blog.html" method="post" enctype="multipart/form-data" accept-charset="UTF-8"> <form action="Blog.html" method="post" enctype="multipart/form-data" accept-charset="UTF-8">
<input type="submit" value="No, leave it." /> <input type="submit" class="btn btn-primary" value="No, leave it." />
</form> </form>
</fieldset> </fieldset>
:: ::
@ -157,7 +157,7 @@
<form action="Blog.html" method="post" enctype="multipart/form-data" accept-charset="UTF-8"> <form action="Blog.html" method="post" enctype="multipart/form-data" accept-charset="UTF-8">
<fieldset> <fieldset>
<input type="file" size="50" name="xmlfile" /> <input type="file" size="50" name="xmlfile" />
<input type="submit" name="importxml" value="Import" /> <input type="submit" name="importxml" class="btn btn-primary" value="Import" />
</fieldset> </fieldset>
</form> </form>
#(/mode)# #(/mode)#

@ -70,9 +70,9 @@
</dd> </dd>
</dl> </dl>
<input type="hidden" name="page" value="#[pageid]#" /> <input type="hidden" name="page" value="#[pageid]#" />
<input type="submit" name="submit" value="Submit" /> <input type="submit" name="submit" class="btn btn-primary" value="Submit" />
<input type="submit" name="preview" value="Preview" /> <input type="submit" name="preview" class="btn btn-default" value="Preview" />
<input type="submit" name="view" value="Discard" /> <input type="submit" name="view" class="btn btn-danger" value="Discard" />
</fieldset> </fieldset>
</form> </form>
#(/allow)# #(/allow)#
@ -109,9 +109,9 @@
</dl> </dl>
<input type="hidden" name="page" value="#[pageid]#" /> <input type="hidden" name="page" value="#[pageid]#" />
<!-- <input type="text" name="page" value="#[pageid]#" /> --> <!-- <input type="text" name="page" value="#[pageid]#" /> -->
<input type="submit" name="submit" value="Submit" /> <input type="submit" name="submit" class="btn btn-primary" value="Submit" />
<input type="submit" name="preview" value="Preview" /> <input type="submit" name="preview" class="btn btn-default" value="Preview" />
<input type="submit" name="view" value="Discard" /> <input type="submit" name="view" class="btn btn-danger" value="Discard" />
</fieldset> </fieldset>
</form> </form>

@ -159,18 +159,19 @@ public class BlogBoard {
} }
public boolean importXML(final String input) { public boolean importXML(final String input) {
final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); if (input != null && !input.isEmpty()) {
try { final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
final DocumentBuilder builder = factory.newDocumentBuilder(); try {
return parseXMLimport(builder.parse(new ByteArrayInputStream(UTF8.getBytes(input)))); final DocumentBuilder builder = factory.newDocumentBuilder();
} catch (final ParserConfigurationException ex) { return parseXMLimport(builder.parse(new ByteArrayInputStream(UTF8.getBytes(input))));
ConcurrentLog.logException(ex); } catch (final ParserConfigurationException ex) {
} catch (final SAXException ex) { ConcurrentLog.logException(ex);
ConcurrentLog.logException(ex); } catch (final SAXException ex) {
} catch (final IOException ex) { ConcurrentLog.logException(ex);
ConcurrentLog.logException(ex); } catch (final IOException ex) {
ConcurrentLog.logException(ex);
}
} }
return false; return false;
} }

Loading…
Cancel
Save