NetTalk Central
NetTalk Web Server => Web Server - Ask For Help => Topic started by: debzidoodle on April 29, 2014, 04:57:05 AM
-
Hi Bruce,
Is there a function that will perform Percent Encoding? The p_web.EncodeWebString is a little to agressive, percent encoding is like the PHP function rawurlencode https://php.net/manual/en/function.rawurlencode.php
Thanks
Debra
-
Hi Debra,
>> The p_web.EncodeWebString is a little too aggressive...
You need to qualify this a bit. This method does "percent encoding" but it does take a "flags" parameter which can alter the behavior a bit. Flags is a "bitwise" parameter, meaning you can add these equates together.
For example, setting flags to Net:Dos means the following characters are not encoded
/ \ . $
If flags includes net:NoHex or net:NoPlus then spaces are left along.
If flags contains net:BigPlus then spaces are encoded to %20.
Otherwise spaces are encoded as +
if flags contains net:NoColon then colons are not encoded.
All letters (A-Z and a-z) and numbers (0-9) are not encoded.
Everything not mentioned above, is encoded.
Sorry to answer your question more completely, I need to know what you find "too aggressive" about it. :)
Cheers
Bruce
-
The flags is what I was missing... I overlooked that somehow :)
It almost gets me where I need to be with the net:dos, except I need the / encoded. Or you could look at it another way, I need to keep the . with a non-flag encode.
I am doing oAuth, and I have to make the strings encoded in my signature. So here is an example of a string as it has to be encoded for the signature to be valid
This is my string
oauth_callback='http://10.211.55.4:88/qbGetOAuthAccessToken'
I need it to look like this
oauth_callback_Encoded = 'http%3A%2F%2F10.211.55.4%3A88%2FqbGetOAuthAccessToken'
p_web.encodeWebstring(oauth_callback,net:dos) gives me 'http%3A//10.211.55.4%3A88/qbGetOAuthAccessToken'
and
p_web.encodeWebstring(oauth_callback) gives me 'http%3A%2F%2F10%2E211%2E55%2E4%3A88%2FqbGetOAuthAccessToken'
Edit:
Here is a description of what I need:
Returns a string in which all non-alphanumeric characters except -_.~ have been replaced with a percent (%) sign followed by two hex digits. This is the encoding described in ยป RFC 3986 for protecting literal characters from being interpreted as special URL delimiters, and for protecting URLs from being mangled by transmission media with character conversions (like some email systems).
I found this here: http://stackoverflow.com/questions/996139/urlencode-vs-rawurlencode
Thank you!
Debra
-
Hi Debra,
I've added a flag net:php for the next build which preserves that combination. I suspect you'll want to use it in combination with net:BigPlus
Cheers
Bruce
-
Thank you!!!