Query string parameters are decoded with the URL prior to passing to a custom URL Rewriter
Last updated 2022-02-10 ·Reference W-3639275 ·Reported By 2 users
Summary
Query string parameters are decoded with the URL prior to passing to a custom Site URL Rewriter.
Repro
1. Create a Site URL rewriter class and assign it to a site:
global with sharing class testUrlRewriter implements Site.UrlRewriter {
global PageReference mapRequestUrl(PageReference pageRefIn) {
String url = pageRefIn.getUrl();
Map<String,String> params = pageRefIn.getParameters();
if (url.contains('/mypages/')) {
PageReference pageRefOut = new PageReference('/MySitePage');
System.debug(pageRefIn.getUrl()); //ISSUE: the url passed to the rewriter already has some characters escaped
String param = params.get('ref');
System.debug(pageRefOut);
pageRefOut.getParameters().put('id',params.get('ref'));
return pageRefOut;
}
global PageReference[] generateUrlFor(PageReference[] yourSalesforceUrls) {
return null;
}
}
2. Create a Visualforce page for the site "MySitePage:
<apex:page showHeader="false" sidebar="false">
<h1>My Site Page</h1>
<p>Id: {!$CurrentPage.parameters.id}</p>
</apex:page>
3. Access the page using the following urls via the site:
a. /mypages/mypage?ref=my%2Bvalue%2C
b. /mypages/mypage?ref=my%26value
ACTUAL:
The query string parameters are incorrectly interpreted (or excluded in the case of the escaped ambersand):
3a. my%2Bvalue%2C ==> my+value%2C ==> "my value,"
3b. my%26value ==> my&value%2C ==> null
EXPECTED:
The query string parameters should be correctly encoded when passed to the url rewriter class:
3a. my%2Bvalue%2C ==> my%2Bvalue%2C ==> "my+value,"
3b. my%26value ==> my%26value ==> "my&value"
Workaround
N/A
Reported By (2)
Is it Fixed?
Any unreleased services, features, statuses, or dates referenced in this or other public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make their purchase decisions based upon features that are currently available.