🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #8705

UrlEscape

#8705
From: Angel
Date: Tue, 28 Sep 2004 11:54
46 lines
2269 bytes
Hello to all in the group.

I have an URL like this:

http://www.myserver.com:8080/myservlet?query1=value one&query2=%value two%

and I want the '%' characters escaped.


I am using the following code:

(The original url is in the szBuffer variable)

char szQueryBuffer[INTERNET_MAX_URL_LENGTH] = {0};
DWORD dwQueryBufferLen = INTERNET_MAX_URL_LENGTH;

char szEscapedBuffer[INTERNET_MAX_URL_LENGTH] = {0};
DWORD dwEscapedBufferLen = INTERNET_MAX_URL_LENGTH;

char szFinalBuffer[INTERNET_MAX_URL_LENGTH] = {0};
DWORD dwFinalBufferLen = INTERNET_MAX_URL_LENGTH;

//Here I get the Query part of the URL
UrlGetPart(szBuffer,szQueryBuffer,&dwQueryBufferLen,URL_PART_QUERY,URL_PARTFLAG_KEEPSCHEME);

//Escape the query part
HRESULT QueryRes = 
UrlEscape(szQueryBuffer,szEscapedBuffer,&dwEscapedBufferLen,URL_ESCAPE_PERCENT);

if(QueryRes==S_OK)
{
   //Put the '?' char back into the escaped query
   memmove(szEscapedBuffer+1,szEscapedBuffer, strlen(szEscapedBuffer));
   szEscapedBuffer[0]='?';
   //Combine the URL
   HRESULT Result = UrlCombine( 
szBuffer,szEscapedBuffer,szFinalBuffer,&dwFinalBufferLen,ICU_BROWSER_MODE);
}

But this code escapes ALL the unsafe characters in the query part 
including the '&' and the blank spaces, not only the percentage signs 
that is what I want.

Is there any solution to my problem?

TIA
Technical Details
Message-ID: <41595117$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!peernews-us.colt.net!colt.net!peernews3.colt.net!newsfeed00.sul.t-online.de!t-online.de!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,5197fec0940ada91,start
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Tue, 28 Sep 2004 13:54:05 +0200
From: Angel <user@example.net>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.2) Gecko/20040803
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: UrlEscape 
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 213.37.37.240
Message-ID: <41595117$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1096372503 213.37.37.240 (28 Sep 2004 04:55:03 -0700)
Lines: 46
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!peernews-us.colt.net!colt.net!peernews3.colt.net!newsfeed00.sul.t-online.de!t-online.de!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail