You are not logged in.
url encoding in RFC3986 is different from urlEncode in mormot.core.buffers. Spaces cannot be replaced with +
Offline
You are right: current UrlEncode/UrlDecode are for URI parameters, in which spaces are converted into the plus sign.
But for the main URI itself, it won't work as expected by RFC 3986.
Please try and check the new UrlEncodeName/UrlDecodeName functions:
https://github.com/synopse/mORMot2/commit/60f30baa
Online
Thanks for your quick response, but shouldn't the space2plus argument for calling _UrlEncode_ComputeLen in urlencodeName be 48('0')? Should it be 43('+').
Offline
In RFC3986, should '+'(43) be converted to %43?
Offline
RFC3986 rules will not encode ~, PHP rawUrlEncode from version 5.3 support RFC3986, the previous version will encode ~, Ali, Tencent api coding is to follow this rule.
Offline
AFAIK '+'(43) should be converted to '%2B'.
As it is the case:
https://github.com/synopse/mORMot2/commit/4fa6b86a
About tilde ('~') this is a debate matter.
See https://blog.synopse.info/?post/2020/08 … -The-Tilde
and https://jkorpela.fi/tilde.html
The RFC should better not be followed in practice for this character.
Online
or You can add an argument to the urlencode(urlEncodeName) function, and it is up to the user to decide whether ~ is encoded or not
Offline
api calls from ali,tencent, or other services will sign the encoded url. If the encoding results are inconsistent, the signature verification will fail
Offline
The encoded URI is transmitted, but a signature field is added, and the signature field is based on this encoded URI. The result is definitely different if the string contains ~ and %7E
Offline
Yes, but I guess that since it is the client which makes the encoding, the signature will take it into account, because everything is done on the client side.
The result is different but still properly signed, and could properly be decoded on the server side.
I can't see how it may fail.
Online
Thank you. I'll test it later
Offline
I find using TDocVariantData sortByName, and toUrlEncode can satisfy many platform API calls, if the toUrlEncode can choose encoding rules: use urlEncode or urlencodeName, so much the better
Offline