Author: jacopoc
Date: Tue Sep 8 12:46:28 2009
New Revision: 812483
URL:
http://svn.apache.org/viewvc?rev=812483&view=revLog:
Fix for error happening when using a csv export with fields containing quotes.
Modified:
ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java
ofbiz/trunk/framework/widget/config/widget.properties
ofbiz/trunk/framework/widget/templates/csvFormMacroLibrary.ftl
Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java?rev=812483&r1=812482&r2=812483&view=diff==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java Tue Sep 8 12:46:28 2009
@@ -78,6 +78,7 @@
public static final SimpleEncoder htmlEncoder = new HtmlEncoder();
public static final SimpleEncoder xmlEncoder = new XmlEncoder();
+ public static final SimpleEncoder stringEncoder = new StringEncoder();
public static interface SimpleEncoder {
public String encode(String original);
@@ -95,6 +96,15 @@
}
}
+ public static class StringEncoder implements SimpleEncoder {
+ public String encode(String original) {
+ if (original != null) {
+ original = original.replace("\"", "\\\"");
+ }
+ return original;
+ }
+ }
+
// ================== Begin General Functions ==================
public static SimpleEncoder getEncoder(String type) {
@@ -102,6 +112,8 @@
return StringUtil.xmlEncoder;
} else if ("html".equals(type)) {
return StringUtil.htmlEncoder;
+ } else if ("string".equals(type)) {
+ return StringUtil.stringEncoder;
} else {
return null;
}
Modified: ofbiz/trunk/framework/widget/config/widget.properties
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/config/widget.properties?rev=812483&r1=812482&r2=812483&view=diff==============================================================================
--- ofbiz/trunk/framework/widget/config/widget.properties (original)
+++ ofbiz/trunk/framework/widget/config/widget.properties Tue Sep 8 12:46:28 2009
@@ -75,5 +75,6 @@
screencsv.formrenderer=component://widget/templates/csvFormMacroLibrary.ftl
screencsv.menurenderer=component://widget/templates/csvMenuMacroLibrary.ftl
screencsv.treerenderer=component://widget/templates/csvTreeMacroLibrary.ftl
+screencsv.encoder=string
screencsv.default.contenttype=UTF-8
screencsv.default.encoding=none
Modified: ofbiz/trunk/framework/widget/templates/csvFormMacroLibrary.ftl
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/templates/csvFormMacroLibrary.ftl?rev=812483&r1=812482&r2=812483&view=diff==============================================================================
--- ofbiz/trunk/framework/widget/templates/csvFormMacroLibrary.ftl (original)
+++ ofbiz/trunk/framework/widget/templates/csvFormMacroLibrary.ftl Tue Sep 8 12:46:28 2009
@@ -17,7 +17,7 @@
under the License.
-->
-<#macro renderField text><#if text?exists>"${text?replace("\"", "\"\"")}"</#if></#macro>
+<#macro renderField text>"<#if text?exists>${text?replace("\\\"", "\"\"")}"</#if></#macro>
<#macro renderDisplayField idName description class alert inPlaceEditorId="" inPlaceEditorUrl="" inPlaceEditorParams="">
<@renderField description />,<#rt/>