Layer7 API Management

 View Only

URL Encoding the space character

  • 1.  URL Encoding the space character

    Posted Apr 19, 2022 04:11 PM
    Edited by Jackie Wilson Apr 20, 2022 12:43 AM
    The URL encoding of the Encode/Decode Data assertion makes no distinction between the URL path and the URL query when encoding space characters.  It always encodes the space character as a "+" instead of "%20".  The "+" character is a valid character in a URL path so when spaces are encoded as "+" it makes the URL ****. 

    The reason given by Broadcom in the response below is that in HTML form data the space character is encoded with "+".  However, that only applies to application/x-www-form-urlencoded (i.e. the query) not the URL path.

    https://community.broadcom.com/enterprisesoftware/communities/community-home/digestviewer/viewthread?GroupId=1255&MID=777073&CommunityKey=0f580f5f-30a4-41de-a75c-e5f433325a18&tab=digestviewer

    The Encode/Decode Data needs to be extended to allow the choice of "+" or "%20" to encode a space or even better, to differentiate between the URL parts. JavaScript has the separate encodeURI and encodeURIComponent functions to handle these use cases.

    Edit: Any idea why the word i-n-v-a-l-i-d is replaced with **** ?