Hey, I managed to fix this issue with this very simple patch. I don't know what
else is going on, so can someone review it? I suspect if the output can be
something other than xml, then this needs to be a little more sophisticated.
- Leon
Leon Torres wrote:
I tried using the DataFile tool to import some CSV with Strings that
contain quote characters (") such as, 6" x 6" Napkin. The resulting
xml didn't replace these with " so I get a malformed
entity-engine-xml.
How do I do that?
I looked at the source code and it doesn't seem to do any escaping in
Record.setString().
- Leon
Index: framework/datafile/src/org/ofbiz/datafile/Record.java
===================================================================
--- framework/datafile/src/org/ofbiz/datafile/Record.java (revision 1431)
+++ framework/datafile/src/org/ofbiz/datafile/Record.java (working copy)
@@ -36,6 +36,8 @@
import java.util.StringTokenizer;
import java.util.NoSuchElementException;
+import org.ofbiz.base.util.UtilFormatOut;
+
/**
* Record
*
@@ -261,7 +263,7 @@
set(name, new Double(number));
} // standard types
else if (fieldType.equals("java.lang.String") || fieldType.equals("String"))
- set(name, value);
+ set(name, UtilFormatOut.encodeXmlValue(value));
else if (fieldType.equals("NullTerminatedString")) {
int terminate = value.indexOf(0x0);
set(name, terminate>0?value.substring(0,terminate):value);