fix NPE on empty blog importfile parameter

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

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

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

@ -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;
}

Loading…
Cancel
Save