You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by sa...@apache.org on 2012/03/08 17:15:55 UTC
svn commit: r1298456 -
/ofbiz/branches/release10.04/framework/widget/src/org/ofbiz/widget/WidgetWorker.java
Author: sascharodekamp
Date: Thu Mar 8 16:15:54 2012
New Revision: 1298456
URL: http://svn.apache.org/viewvc?rev=1298456&view=rev
Log:
No Url encoding for get parameters (https://issues.apache.org/jira/browse/OFBIZ-2628) using the URLEncoder to encode and render URLs with special Chars. The encoding is always UTF-8. Fixed Patch without the HTTPS redirect bug.
Modified:
ofbiz/branches/release10.04/framework/widget/src/org/ofbiz/widget/WidgetWorker.java
Modified: ofbiz/branches/release10.04/framework/widget/src/org/ofbiz/widget/WidgetWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release10.04/framework/widget/src/org/ofbiz/widget/WidgetWorker.java?rev=1298456&r1=1298455&r2=1298456&view=diff
==============================================================================
--- ofbiz/branches/release10.04/framework/widget/src/org/ofbiz/widget/WidgetWorker.java (original)
+++ ofbiz/branches/release10.04/framework/widget/src/org/ofbiz/widget/WidgetWorker.java Thu Mar 8 16:15:54 2012
@@ -20,9 +20,11 @@ package org.ofbiz.widget;
import java.io.IOException;
import java.io.StringWriter;
+import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
+import java.net.URLEncoder;
+import java.nio.charset.Charset;
import java.text.DateFormat;
-import java.util.List;
import java.util.Map;
import java.util.TimeZone;
@@ -316,9 +318,14 @@ public class WidgetWorker {
public String getValue(Map<String, Object> context) {
if (this.value != null) {
- return this.value.expandString(context);
+ try {
+ return URLEncoder.encode(this.value.expandString(context), Charset.forName("UTF-8").displayName());
+ } catch (UnsupportedEncodingException e) {
+ Debug.logError(e, module);
+ return this.value.expandString(context);
+ }
}
-
+
Object retVal = null;
if (this.fromField != null && this.fromField.get(context) != null) {
retVal = this.fromField.get(context);
@@ -329,7 +336,7 @@ public class WidgetWorker {
if (retVal != null) {
TimeZone timeZone = (TimeZone) context.get("timeZone");
if (timeZone == null) timeZone = TimeZone.getDefault();
-
+
String returnValue = null;
// format string based on the user's time zone (not locale because these are parameters)
if (retVal instanceof Double || retVal instanceof Float || retVal instanceof BigDecimal) {
@@ -347,7 +354,11 @@ public class WidgetWorker {
DateFormat df = UtilDateTime.toDateTimeFormat("EEE MMM dd hh:mm:ss z yyyy", timeZone, null);
returnValue = df.format((java.util.Date) retVal);
} else {
- returnValue = retVal.toString();
+ try {
+ returnValue = URLEncoder.encode(retVal.toString(), Charset.forName("UTF-8").displayName());
+ } catch (UnsupportedEncodingException e) {
+ Debug.logError(e, module);
+ }
}
return returnValue;
} else {
@@ -378,7 +389,7 @@ public class WidgetWorker {
/** Returns the script location based on a script combined name:
* <code>location#methodName</code>.
- *
+ *
* @param combinedName The combined location/method name
* @return The script location
*/
@@ -393,7 +404,7 @@ public class WidgetWorker {
/** Returns the script method name based on a script combined name:
* <code>location#methodName</code>. Returns <code>null</code> if
* no method name is found.
- *
+ *
* @param combinedName The combined location/method name
* @return The method name or <code>null</code>
*/