Author: jonesde
Date: Fri Feb 6 09:40:37 2009 New Revision: 741496 URL: http://svn.apache.org/viewvc?rev=741496&view=rev Log: Small update to use OWASP ESAPI Encoder instead of java.net.URLEncoder for parameter strings Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilHttp.java Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilHttp.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilHttp.java?rev=741496&r1=741495&r2=741496&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilHttp.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilHttp.java Fri Feb 6 09:40:37 2009 @@ -24,10 +24,8 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.io.UnsupportedEncodingException; import java.net.FileNameMap; import java.net.URLConnection; -import java.net.URLEncoder; import java.sql.Timestamp; import java.util.ArrayList; import java.util.Arrays; @@ -73,10 +71,12 @@ /** OWASP ESAPI canonicalize strict flag; setting false so we only get warnings about double encoding, etc; can be set to true for exceptions and more security */ public static final boolean esapiCanonicalizeStrict = false; public static final Encoder defaultWebEncoder; + //public static final Validator defaultWebValidator; static { // possible codecs: CSSCodec, HTMLEntityCodec, JavaScriptCodec, MySQLCodec, OracleCodec, PercentCodec, UnixCodec, VBScriptCodec, WindowsCodec List<Codec> codecList = Arrays.asList(new CSSCodec(), new HTMLEntityCodec(), new JavaScriptCodec(), new PercentCodec()); - defaultWebEncoder = new DefaultEncoder( codecList ); + defaultWebEncoder = new DefaultEncoder(codecList); + //defaultWebValidator = new DefaultValidator(); } public static final String MULTI_ROW_DELIMITER = "_o_"; @@ -748,16 +748,26 @@ } } try { + buf.append(defaultWebEncoder.encodeForURL(name)); + } catch (EncodingException e) { + Debug.logError(e, module); + } + /* the old way: try { buf.append(URLEncoder.encode(name, "UTF-8")); } catch (UnsupportedEncodingException e) { Debug.logError(e, module); - } + } */ buf.append('='); try { + buf.append(defaultWebEncoder.encodeForURL(valueStr)); + } catch (EncodingException e) { + Debug.logError(e, module); + } + /* the old way: try { buf.append(URLEncoder.encode(valueStr, "UTF-8")); } catch (UnsupportedEncodingException e) { Debug.logError(e, module); - } + } */ } } } |
Free forum by Nabble | Edit this page |