From 40788807eeced941c718bb28373a73413f462cb5 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Thu, 30 Oct 2014 16:57:44 -0400 Subject: [PATCH] y'all should handle nulls too --- core/src/processing/data/Table.java | 34 +++++++++++++++-------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/core/src/processing/data/Table.java b/core/src/processing/data/Table.java index e9b221a55..82bf5b11f 100644 --- a/core/src/processing/data/Table.java +++ b/core/src/processing/data/Table.java @@ -1301,22 +1301,24 @@ public class Table { // save us from having to create the entire document in memory again before // writing to the file. So while it's dorky, the outcome is still useful. StringBuilder sanitized = new StringBuilder(); - char[] array = text.toCharArray(); - for (char c : array) { - if (c == '&') { - sanitized.append("&"); - } else if (c == '\'') { - sanitized.append("'"); - } else if (c == '"') { - sanitized.append("""); - } else if (c == '<') { - sanitized.append("<"); - } else if (c == '>') { - sanitized.append("&rt;"); - } else if (c < 32 || c > 127) { - sanitized.append("&#" + ((int) c) + ";"); - } else { - sanitized.append(c); + if (text != null) { + char[] array = text.toCharArray(); + for (char c : array) { + if (c == '&') { + sanitized.append("&"); + } else if (c == '\'') { + sanitized.append("'"); + } else if (c == '"') { + sanitized.append("""); + } else if (c == '<') { + sanitized.append("<"); + } else if (c == '>') { + sanitized.append("&rt;"); + } else if (c < 32 || c > 127) { + sanitized.append("&#" + ((int) c) + ";"); + } else { + sanitized.append(c); + } } }