Archive: InetLoad un-URLEncoding


InetLoad un-URLEncoding
When I use InetLoad to do an HTTP GET with URLEncoded data, I see with ethereal that what goes through is not URLEncoded.

When I try the same thing with NSISdl, the data goes through encoded properly.

I searched InetLoad.cpp quickly and didn't see any relevant encoding references. Any ideas why this is happening? I can use NSISdl for this GET, but I'm curious as to what caused this.


GET requests worked correct in my tests ;) Can you give a script sample? And what you see in ethereal. Current version adds "Content-Type: application/x-www-form-urlencoded" header to POST requests only (if you had in mind this). I know it is possible to move FORM data to header URL for GET requests, but this is not implemented yet (and not required I guess).


When I do this test:


Name "gettest"
Outfile "gettest.exe"
Section ""
SectionEnd
Function .onInit
InitPluginsDir
GetTempFileName $0 $PLUGINSDIR
Rename $0 "$0.htm"
StrCpy $R1 "hi%20%3a%29" # "hi :)"
InetLoad::load "$my_server/$R1" "$0.htm"
;NSISdl::download "$my_server/$R1" "$0.htm"
FunctionEnd

I see this in ethereal:
Inetload:
hi%20:)
68 69 25 32 30 3a 29

NSISdl:
hi%20%3a%29
68 69 25 32 30 25 33 61 25 32 39

It seems like NSISdl is sending what I passed ($R1), but Inetload seems to be converting the "%3a%29" to the hex values "3a29". Both may be fine with the server, but I was surprised to see this and wanted to point it out in case it may be an issue. Sorry about the smiley in the example, I didn't think about it at the time.

You can use the Disable Smilies in This Post check box, if you don't use the quick reply box or if you edit your message. I've disabled it for you in your last post.


I am not sure where this happens precisely - InternetCrackUrl, InternetConnect or somewhere else (this may be tested with simple MessageBox'es), but WinInet probably has some reasons to do this, smiles might be allowed in the http get ;)
In my tests POST (form) data were sent to server unconverted, so you can use this method. php example included to package.


It doesn't just happen with smilies, but you are right, it seems to be InternetCrackUrl. I MessageBox'd before and after this line:


if(InternetCrackUrl(url, 0, ICU_ESCAPE , &uc))

The value before was what I passed in, and the value after was unencoded. Looks like it's the ICU_ESCAPE that does it:
Converts all escape sequences (%xx) to their corresponding characters.
I have to use a GET with URLEncoded data for this particular situation, so I'll go with NSISdl for that, but I have to POST other times, and Inetload works perfectly for that.

Thanks for the quick responses and helping me figure out what was happening :)

You can rebuild plug-in with InternetCrackUrl(url, 0, 0, &uc) for your needs ;)


Ah, cool. The MSDN documentation had me thinking that you had to either use ICU_DECODE or ICU_ESCAPE. Thanks!