From 5db56d8d2ca66564f1fb663d4b002b1fde595f76 Mon Sep 17 00:00:00 2001 From: "David E. Jones" Date: Sat, 18 Nov 2006 08:30:52 +0000 Subject: [PATCH] Applied patch from Fabian Gorsler to escape certain characters to avoid problems in the XML export/import; changed to not use the codePointAt method because it is only supported in Java 5; Jira #OFBIZ-453 git-svn-id: https://svn.apache.org/repos/asf/incubator/ofbiz/trunk@476469 13f79535-47bb-0310-9956-ffa450edef68 --- framework/entity/src/org/ofbiz/entity/GenericEntity.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/framework/entity/src/org/ofbiz/entity/GenericEntity.java b/framework/entity/src/org/ofbiz/entity/GenericEntity.java index a25f5f7604..565e732ed1 100644 --- a/framework/entity/src/org/ofbiz/entity/GenericEntity.java +++ b/framework/entity/src/org/ofbiz/entity/GenericEntity.java @@ -1052,6 +1052,13 @@ public class GenericEntity extends Observable implements Map, LocalizedMap, Seri // if it is less that 0x20 at this point it is invalid because the only valid values < 0x20 are 0x9, 0xA, 0xD as caught above Debug.logInfo("Removing invalid character [" + curChar + "] numeric value [" + (int) curChar + "] for field " + name + " of entity with PK: " + this.getPrimaryKey().toString(), module); value.deleteCharAt(i); + }else if(curChar > 0x7F) { + // Replace each char which is out of the ASCII range with a XML entity + String replacement = "&#" + (int) curChar + ";"; + if(Debug.verboseOn()) { + Debug.logVerbose("Entity: "+ this.getEntityName() +", PK: " + this.getPrimaryKey().toString() +" -> char ["+ curChar +"] replaced with ["+ replacement +"]", module); + } + value.replace(i, i+1, replacement); } } }