Skip to content

Commit 09d6ee6

Browse files
committed
y'all should handle nulls too
1 parent 5790e2e commit 09d6ee6

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

core/src/processing/data/Table.java

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,22 +1301,24 @@ void saveStringODS(OutputStream output, String text) throws IOException {
13011301
// save us from having to create the entire document in memory again before
13021302
// writing to the file. So while it's dorky, the outcome is still useful.
13031303
StringBuilder sanitized = new StringBuilder();
1304-
char[] array = text.toCharArray();
1305-
for (char c : array) {
1306-
if (c == '&') {
1307-
sanitized.append("&");
1308-
} else if (c == '\'') {
1309-
sanitized.append("'");
1310-
} else if (c == '"') {
1311-
sanitized.append(""");
1312-
} else if (c == '<') {
1313-
sanitized.append("&lt;");
1314-
} else if (c == '>') {
1315-
sanitized.append("&rt;");
1316-
} else if (c < 32 || c > 127) {
1317-
sanitized.append("&#" + ((int) c) + ";");
1318-
} else {
1319-
sanitized.append(c);
1304+
if (text != null) {
1305+
char[] array = text.toCharArray();
1306+
for (char c : array) {
1307+
if (c == '&') {
1308+
sanitized.append("&amp;");
1309+
} else if (c == '\'') {
1310+
sanitized.append("&apos;");
1311+
} else if (c == '"') {
1312+
sanitized.append("&quot;");
1313+
} else if (c == '<') {
1314+
sanitized.append("&lt;");
1315+
} else if (c == '>') {
1316+
sanitized.append("&rt;");
1317+
} else if (c < 32 || c > 127) {
1318+
sanitized.append("&#" + ((int) c) + ";");
1319+
} else {
1320+
sanitized.append(c);
1321+
}
13201322
}
13211323
}
13221324

0 commit comments

Comments
 (0)