JIRA

  • Log In Access more options
    • Online Help
    • GreenHopper Help
    • Agile Answers
    • Use Agile By Default
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What’s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • Agile Access more options (Alt+g)
  • Create Issue
  • Mule
  • MULE-4912

HttpRequestBodyToParamMap uses java.net.URLDecoder. But URLDecoder sometimes can't decode query string which encoded by URLCodec.

  • Agile Board
  • More Actions
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 3.0.0-M4
  • Fix Version/s: 3.1.0
  • Component/s: Transport: HTTP(S) / Jetty
  • Labels:
    None
  • Environment:

    WindowsXP SP3, Sun JDK 1.6.0_14

  • User impact:
    Medium
  • Similar Issues:
    None

Description

Hi.

At first, please check out MULE-4911.

I found a one more problem in HttpRequestBodyToParamMap class.

HttpRequestBodyToParamMap uses java.net.URLDecoder.
But when multibytes string is used, URLDecoder sometimes can't decode query string which encoded by URLCodec.

For example, Japanese Hiragana characher "\u30a8" is encoded to...
=> "%83%47" (by URLEncoder)
=> "%83G" (by URLCodec)

===== sample code =====
import java.net.URLDecoder;
import java.net.URLEncoder;

import org.apache.commons.codec.net.URLCodec;
import org.junit.Assert;
import org.junit.Test;

public class URLDecoderTest {

private static final String encoding = "Windows-31J";
private static final String value = "\u30a8"; // a Japanese hiragana character

@Test
public void testDecode() throws Exception { System.out.println(URLEncoder.encode(value, encoding)); System.out.println(new URLCodec().encode(value, encoding)); Assert.assertEquals(value, URLDecoder.decode(new URLCodec().encode(value, encoding), encoding)); }

}
===== sample code =====

And according to RFC3986 (Sec 2.3)...
> For consistency, percent-encoded octets in the ranges of ALPHA
> (%41-%5A and %61-%7A), DIGIT (%30-%39), hyphen (%2D), period (%2E),
> underscore (%5F), or tilde (%7E) should not be created by URI
> producers

In the case of "\u30a8", "%83G"(by URLCodec) is preferred result. (correct?)

But URLDecoder can't decode "%83G" to "\u30a8". and URLCodec#decode() can.
So I think that URLCodec#docode() should be used here instead of URLDecoder.

Here is a patch for this problem and functional tests.
(this patch includes all the content of the patch for MULE-4911)

best regards.

  • Options
    • Sort By Name
    • Sort By Date
    • Ascending
    • Descending
    • Download All

Attachments

  1. Text File
    NEW-URLDecoder.patch
    20/Jun/10 09:55 PM
    15 kB
    Kazuya Uno
  2. Text File
    URLDecoder.patch
    18/Jun/10 01:11 AM
    13 kB
    Kazuya Uno

Activity

  • All
  • Comments
  • Work Log
  • History
  • Activity
  • Transitions
  • Commits
  • Source
  • Builds

CE Bamboo View RSS feed

People

  • Assignee:
    Dirk Olmes
    Reporter:
    Kazuya Uno
Vote (0)
Watch (1)

Dates

  • Created:
    18/Jun/10 01:10 AM
    Updated:
    18/Nov/10 08:57 AM
    Resolved:
    18/Nov/10 08:57 AM

Agile

  • View on Board
  • Atlassian JIRA (v5.0.7#734-sha1:8ad78a6)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for MuleForge. Try JIRA - bug tracking software for your team.