On Thu, 18 Nov 2004 23:02:07 -0500, "George Hester"
<> wrote:
>This code has problems. If the URL contains a parameter
>which is an image like blondie.jpg then what is sent to the
>Logon page is NOT the URL that ostensibly was sent to the
>logon page. Not only does it look different obviously but
>it IS different.
>
>If the URL accessed (mypage.asp) is like this:
>
>http://www.mydomain.com/more.asp?image=blondie.jpg
>
>Then what is sent to the logon page looks like this:
>
>http://www.mydomain.com/logon.asp?fr...londie%252Ejpg
>
>This is because the Request.ServerVariables("URL") does a
>little bit of encoding It encodes . to %2E and therefore when
>we pass this into Server.URLEncode it strips out the % and puts
>it as %25 and leaves the 2E alone. This then causes an error in
>JavaScript.
>
OK, so simply unencode the URL before encoding it again. If your
script can't cope with encoded URLs it's going to break anyway
someday...
I'm not saying this is the best way to do it, but off the top of my
head:
const Hexconvert = "0123456789ABCDEF"
function firsttwoHextoAscii(strHex)
dim dec
firsttwoHextoAscii = ""
if len(strHex)>1 then
dec = 16 * instr(1,Hexconvert,left(strHex,1),1) + _
instr(1,Hexconvert,mid(strHex,2,1),1) - 17
if dec>0 and dec<256 then
firsttwoHextoAscii = chr(dec)
end if
end if
end function
function URLunencode(strEncoded)
dim unencoded,part
if isnull(strEncoded) or strEncoded="" then
URLunencode = ""
else
unencoded = split(replace(strEncoded,"+"," "),"%")
for part = 1 to ubound(unencoded)
unencoded(part) = firsttwoHextoAscii(unencoded(part)) & _
mid(unencoded(part),3)
next
URLunencode = join(unencoded,"")
end if
end function