Skip to content

Commit d1c7c8d

Browse files
committed
PR: Bugzilla Bug 31161 URLCodec.decode() corrupts characters > 127 in unencoded strings Obtained from: Bugzilla Bug 31161 Submitted by: Oleg Kalnichevski Reviewed by: Gary Gregory git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/codec/trunk@130422 13f79535-47bb-0310-9956-ffa450edef68
1 parent 2748aab commit d1c7c8d

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

src/test/org/apache/commons/codec/net/URLCodecTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package org.apache.commons.codec.net;
1818

19+
import java.io.UnsupportedEncodingException;
20+
1921
import junit.framework.TestCase;
2022

2123
import org.apache.commons.codec.DecoderException;
@@ -143,6 +145,18 @@ public void testDecodeInvalid() throws Exception {
143145
this.validateState(urlCodec);
144146
}
145147

148+
public void testDecodeInvalidContent() throws UnsupportedEncodingException, DecoderException {
149+
String ch_msg = constructString(SWISS_GERMAN_STUFF_UNICODE);
150+
URLCodec urlCodec = new URLCodec();
151+
byte[] input = ch_msg.getBytes("ISO-8859-1");
152+
byte[] output = urlCodec.decode(input);
153+
assertEquals(input.length, output.length);
154+
for (int i = 0; i < input.length; i++) {
155+
assertEquals(input[i], output[i]);
156+
}
157+
this.validateState(urlCodec);
158+
}
159+
146160
public void testEncodeNull() throws Exception {
147161
URLCodec urlCodec = new URLCodec();
148162
byte[] plain = null;

0 commit comments

Comments
 (0)