Prevent NPE
(cherry picked from commit 5f2cc2f49f8f043c28056411f945250ed90a39b2)
This commit is contained in:
@@ -1,22 +1,19 @@
|
|||||||
package org.mustangproject;
|
package org.mustangproject;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.dom4j.io.XMLWriter;
|
import org.dom4j.io.XMLWriter;
|
||||||
import org.mustangproject.ZUGFeRD.ZUGFeRD2PullProvider;
|
|
||||||
|
|
||||||
public class XMLTools extends XMLWriter {
|
public class XMLTools extends XMLWriter {
|
||||||
public String escapeAttributeEntities(String s) {
|
@Override
|
||||||
|
public String escapeAttributeEntities(String s) {
|
||||||
return super.escapeAttributeEntities(s);
|
return super.escapeAttributeEntities(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String escapeElementEntities(String s) {
|
@Override
|
||||||
|
public String escapeElementEntities(String s) {
|
||||||
return super.escapeElementEntities(s);
|
return super.escapeElementEntities(s);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -44,8 +41,11 @@ public class XMLTools extends XMLWriter {
|
|||||||
|
|
||||||
|
|
||||||
public static String encodeXML(CharSequence s) {
|
public static String encodeXML(CharSequence s) {
|
||||||
StringBuilder sb = new StringBuilder();
|
if (s == null) {
|
||||||
int len = s.length();
|
return "";
|
||||||
|
}
|
||||||
|
final StringBuilder sb = new StringBuilder();
|
||||||
|
final int len = s.length();
|
||||||
for (int i = 0; i < len; i++) {
|
for (int i = 0; i < len; i++) {
|
||||||
int c = s.charAt(i);
|
int c = s.charAt(i);
|
||||||
if (c >= 0xd800 && c <= 0xdbff && i + 1 < len) {
|
if (c >= 0xd800 && c <= 0xdbff && i + 1 < len) {
|
||||||
@@ -126,7 +126,7 @@ public class XMLTools extends XMLWriter {
|
|||||||
* @return the byte array without bom
|
* @return the byte array without bom
|
||||||
*/
|
*/
|
||||||
public static byte[] removeBOM(byte[] zugferdRaw) {
|
public static byte[] removeBOM(byte[] zugferdRaw) {
|
||||||
byte[] zugferdData;
|
final byte[] zugferdData;
|
||||||
if ((zugferdRaw[0] == (byte) 0xEF) && (zugferdRaw[1] == (byte) 0xBB) && (zugferdRaw[2] == (byte) 0xBF)) {
|
if ((zugferdRaw[0] == (byte) 0xEF) && (zugferdRaw[1] == (byte) 0xBB) && (zugferdRaw[2] == (byte) 0xBF)) {
|
||||||
// I don't like BOMs, lets remove it
|
// I don't like BOMs, lets remove it
|
||||||
zugferdData = new byte[zugferdRaw.length - 3];
|
zugferdData = new byte[zugferdRaw.length - 3];
|
||||||
|
|||||||
Reference in New Issue
Block a user