Search code examples
oracle-apexoracle-apex-18.2

How do I use APEX_UTIL.PREPARE_URL on a URL that contains backslashes?


I'm trying to use APEX_UTIL.PREPARE_URL to produce an APEX URL for a page that requires a checksum, and I'm trying to set a page item on the destination page to a value that contains special characters. Assume for this question that the only special characters that I'm passing are commas, though my problem seems to apply to all special characters.

According to the APEX URL documentation, an item value that contains a comma needs to be enclosed by backslashes. So when I build my URL, I end up with something like this:

f?p=112:50:session::::P50_PAGE_ITEM:\123,abc\:

Then I pass this URL through APEX_UTIL.PREPARE_URL:

APEX_UTIL.PREPARE_URL('f?p=112:50:session::::P50_PAGE_ITEM:\123,abc\:')

When I try to follow the link that's returned, I get the following error:

The checksum computed on the request, clear cache, argument names, and argument values (...) did not match the checksum passed into the show procedure.

If I try passing a value that does not contain commas and I remove the backslashes, the value is passed without a problem.

How can I get a valid checksum for a URL that does contain the backslashes so that I can pass values that contain commas (and other special characters)?


Solution

  • APEX_UTIL.PREPARE_URL should handle backslashes fine. The region that contains the resulting URL may be escaping the special characters, causing the checksum mismatch.

    To test the actual output of APEX_UTIL.PREPARE_URL, try outputting your URL in a PL/SQL Dynamic region. For example:

    DECLARE
      l_url VARCHAR2(200) := 'f?p=112:50:session::::P50_PAGE_ITEM:\123,abc\:';
    BEGIN
      htp.p('<a href="'||apex_util.prepare_url(l_url)||'">page 52</a>');
    END;