Author: sebb Date: Sun Mar 26 18:34:51 2017 New Revision: 1788761 URL: http://svn.apache.org/viewvc?rev=1788761&view=rev Log: CODEC-230 URLCodec.WWW_FORM_URL should be private
Modified: commons/proper/codec/trunk/src/changes/changes.xml commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/net/URLCodec.java Modified: commons/proper/codec/trunk/src/changes/changes.xml URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/changes/changes.xml?rev=1788761&r1=1788760&r2=1788761&view=diff ============================================================================== --- commons/proper/codec/trunk/src/changes/changes.xml (original) +++ commons/proper/codec/trunk/src/changes/changes.xml Sun Mar 26 18:34:51 2017 @@ -45,6 +45,7 @@ The <action> type attribute can be add,u <release version="1.11" date="2017-MM-DD" description="Feature and fix release."> <!-- The first attribute below should be the issue id; makes it easier to navigate in the IDE outline --> + <action issue="CODEC-230" dev="sebb" type="fix">URLCodec.WWW_FORM_URL should be private</action> <action issue="CODEC-229" dev="sebb" type="fix">StringUtils.newStringxxx(null) should return null, not NPE</action> <action issue="CODEC-220" dev="sebb" type="add">Fluent interface for DigestUtils</action> <action issue="CODEC-222" dev="sebb" type="add">Fluent interface for HmacUtils</action> Modified: commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/net/URLCodec.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/net/URLCodec.java?rev=1788761&r1=1788760&r2=1788761&view=diff ============================================================================== --- commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/net/URLCodec.java (original) +++ commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/net/URLCodec.java Sun Mar 26 18:34:51 2017 @@ -64,31 +64,39 @@ public class URLCodec implements BinaryE * Release 1.5 made this field final. */ protected static final byte ESCAPE_CHAR = '%'; + /** * BitSet of www-form-url safe characters. + * @deprecated Will be removed in 2.0 (CODEC-230) */ - protected static final BitSet WWW_FORM_URL = new BitSet(256); + @Deprecated + protected static final BitSet WWW_FORM_URL; + + private static final BitSet WWW_FORM_URL_SAFE = new BitSet(256); // Static initializer for www_form_url static { // alpha characters for (int i = 'a'; i <= 'z'; i++) { - WWW_FORM_URL.set(i); + WWW_FORM_URL_SAFE.set(i); } for (int i = 'A'; i <= 'Z'; i++) { - WWW_FORM_URL.set(i); + WWW_FORM_URL_SAFE.set(i); } // numeric characters for (int i = '0'; i <= '9'; i++) { - WWW_FORM_URL.set(i); + WWW_FORM_URL_SAFE.set(i); } // special chars - WWW_FORM_URL.set('-'); - WWW_FORM_URL.set('_'); - WWW_FORM_URL.set('.'); - WWW_FORM_URL.set('*'); + WWW_FORM_URL_SAFE.set('-'); + WWW_FORM_URL_SAFE.set('_'); + WWW_FORM_URL_SAFE.set('.'); + WWW_FORM_URL_SAFE.set('*'); // blank to be replaced with + - WWW_FORM_URL.set(' '); + WWW_FORM_URL_SAFE.set(' '); + + // Create a copy in case anyone (ab)uses it + WWW_FORM_URL = (BitSet) WWW_FORM_URL_SAFE.clone(); } @@ -123,7 +131,7 @@ public class URLCodec implements BinaryE return null; } if (urlsafe == null) { - urlsafe = WWW_FORM_URL; + urlsafe = WWW_FORM_URL_SAFE; } final ByteArrayOutputStream buffer = new ByteArrayOutputStream(); @@ -191,7 +199,7 @@ public class URLCodec implements BinaryE */ @Override public byte[] encode(final byte[] bytes) { - return encodeUrl(WWW_FORM_URL, bytes); + return encodeUrl(WWW_FORM_URL_SAFE, bytes); }