The current implementation will decode both "+" and "%2B" to SPACE. The replace operation could be performed before decodeURIComponent operation so that "+" is decoded to SPACE and "%2B" is decoded to "+".
Within the query string, the plus sign is reserved as shorthand notation for a space. Therefore, real plus signs must be encoded. This method was used to make query URIs easier to pass in systems which did not allow spaces.
This indicates the expectation that "%2B" should be decoded to the plus sign.
https://github.com/google/caja/blob/d4635c9c014cd3d30c7e36f1d92c950d55a34916/src/com/google/caja/plugin/uri.js#L429
https://github.com/google/caja/blob/d4635c9c014cd3d30c7e36f1d92c950d55a34916/src/com/google/caja/plugin/uri.js#L501
https://github.com/google/caja/blob/d4635c9c014cd3d30c7e36f1d92c950d55a34916/src/com/google/caja/plugin/uri.js#L502
The current implementation will decode both "+" and "%2B" to SPACE. The
replace
operation could be performed beforedecodeURIComponent
operation so that "+" is decoded to SPACE and "%2B" is decoded to "+".Examples
The reference https://www.w3.org/Addressing/URL/4_URI_Recommentations.html states
This indicates the expectation that "%2B" should be decoded to the plus sign.
The reference https://url.spec.whatwg.org/#concept-urlencoded-parser states
This indicates the
replace
operation should be performed before thedecodeURIComponent
operation.