MixedParamUrlCodingStrategy : no symmetric url encoding/decoding ----------------------------------------------------------------
Key: WICKET-739 URL: https://issues.apache.org/jira/browse/WICKET-739 Project: Wicket Issue Type: Bug Components: wicket Affects Versions: 1.3.0-beta2 Environment: wicket-1.3.0-incubator (from maven rep http://wicketstuff.org/maven/repository/) Reporter: David Bernard Priority: Minor I use MixedParamUrlCodingStrategy for BookmarkablePageLink where the first parameter is a String, an human label. And I've got a bug, bad url when I try to link something like "histoire de l'art". During my investigation I found that there is no symmetry between the encoding/decoding of the urlFragment : decodeParameters doesn't decode (urldecode) the fragment of the path. I join the test case (below) ------------------------------------------------------------------- import java.util.HashMap; import java.util.Map; import org.apache.wicket.Page; import org.apache.wicket.request.target.coding.MixedParamUrlCodingStrategy; import org.apache.wicket.util.string.AppendingStringBuffer; import org.apache.wicket.util.tester.WicketTester; import org.apache.wicket.util.value.ValueMap; import org.testng.Assert; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @Test public class MixedParamUrlCodingStrategyTest { private WicketTester wicketTester_; @BeforeClass public void startWicketEnv() throws Exception { wicketTester_ = new WicketTester(); } @AfterClass public void stopWicketEnv() throws Exception { wicketTester_.destroy(); } @DataProvider(name = "params") protected Object[][] paramsProvider() throws Exception { return new Object[][]{ {"value0"}, {"value \u0232\u0224\u0233"}, {"v'alue0"} }; } @SuppressWarnings("unchecked") @Test(dataProvider="params") public void testEncodeDecode(String value) throws Exception { Target target = new Target("/test", Page.class, new String[] { "param0" }); AppendingStringBuffer urlFragment = new AppendingStringBuffer(); Map<String, String> params = new HashMap<String, String>(); urlFragment.setLength(0); params.clear(); params.put("param0", value); target.appendParameters(urlFragment, params); //Assert.assertEquals(urlFragment.toString(), "/value0/value1"); Map urlParams = new HashMap(); ValueMap map = target.decodeParameters(urlFragment.toString(), urlParams); Assert.assertEquals(map.getString("param0"), value); } public static class Target extends MixedParamUrlCodingStrategy { public Target(String mountPath, Class<?> bookmarkablePageClass, String[] parameterNames) { super(mountPath, bookmarkablePageClass, parameterNames); } @SuppressWarnings("unchecked") @Override public void appendParameters(AppendingStringBuffer url, Map parameters) { super.appendParameters(url, parameters); } @SuppressWarnings("unchecked") @Override public ValueMap decodeParameters(String urlFragment, Map urlParameters) { return super.decodeParameters(urlFragment, urlParameters); } } } -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.