ESAPIDecode does not decode + as URLDecode does

Description

As demonstrated in this gist:

https://trycf.com/scratch-pad/gist/adc141f39377d112c5f37f457130c225

ESAPIDecode with the 'url' option will decode %2B as a space rather than a +.

If this is intentional, the docs should reflect it.

If it isn't intentional, it's a bug.

Environment

None

Activity

Show:

Samuel W. Knowlton 9 September 2019 at 13:07

This can be closed, thank you!

Michael Offner 9 September 2019 at 13:01

disagree or can we close it?

Michael Offner 9 September 2019 at 13:01

URLDecode works as expected and work the same way as in AC

https://trycf.com/scratch-pad/gist/adc141f39377d112c5f37f457130c225

Samuel W. Knowlton 31 January 2019 at 03:59

I think this only came up because I had it in my head from some Lucee docs that URLDecode() should be avoided in favor of ESAPIEncode/Decode, but now I can't find it. If there's no push to stop using one and start using the other then it's a non-issue since, as you pointed out, they're not doing the same thing.

This came up for us in transmitting base64-encoded strings to clients for HTTP headers. + is valid there and so we'd just encode it, and had to use URLDecode – ESAPIEncode worked fine but the decode did indeed double-decode it.

Wouldn't hurt to have the docs point that out since I keep leaving my java interface manual in my other pants.

Brad Wood 31 January 2019 at 02:22

I left a comment on Slack too, but I believe this is intentional and more/less in the ESAPI docs. URL Decoding includes canonicalization which removes any double encoded bits of your string. Since a plus sign is a way to encode a space, the plus gets turned into a space for you. I'm fairly sure that's what your hitting. It also means this function is not really suited for a generic encode/process capable of handling any string, but instead can throw away information in some cases and is more suited only for strings in which you would never ever expect to see any meta characters, and if any were found, you would be ok with them being discarded.

Fixed

Details

Assignee

Reporter

Priority

Labels

New Issue warning screen

Before you create a new Issue, please post to the mailing list first https://dev.lucee.org

Once the issue has been verified, one of the Lucee team will ask you to file an issue

Affects versions

Created 30 January 2019 at 22:25
Updated 20 December 2019 at 18:17
Resolved 20 December 2019 at 18:17

Flag notifications