mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-02 23:50:24 +02:00
+ Fix of invalid pointer bug in unescape, from U. Maeder
This commit is contained in:
parent
e240d78c2e
commit
2d7dd81998
@ -309,46 +309,50 @@ function get_value(id: pchar): pchar;
|
|||||||
|
|
||||||
Function UnEscape(QueryString: PChar): PChar;
|
Function UnEscape(QueryString: PChar): PChar;
|
||||||
var
|
var
|
||||||
qunescaped : pchar;
|
qunescaped : pchar;
|
||||||
sptr : longint;
|
sptr : longint;
|
||||||
cnt : word;
|
cnt : word;
|
||||||
qslen : longint;
|
qslen : longint;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
qslen:=strlen(QueryString);
|
qslen:=strlen(QueryString);
|
||||||
if qslen=0 then
|
if qslen=0 then
|
||||||
begin
|
begin
|
||||||
Unescape:=#0;
|
Unescape:=#0;
|
||||||
get_nodata:=true;
|
get_nodata:=true;
|
||||||
exit;
|
exit;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
get_nodata :=false;
|
get_nodata :=false;
|
||||||
{ skelet fix }
|
{ skelet fix }
|
||||||
getmem(qunescaped,qslen+1);
|
getmem(qunescaped,qslen+1);
|
||||||
if qunescaped=nil then
|
if qunescaped=nil then
|
||||||
begin
|
begin
|
||||||
writeln ('Oh-oh');
|
writeln ('Oh-oh');
|
||||||
halt;
|
halt;
|
||||||
end;
|
end;
|
||||||
sptr :=0;
|
sptr :=0;
|
||||||
for cnt := 0 to qslen do
|
|
||||||
begin
|
{ for cnt := 0 to qslen do +++++ use while instead of for }
|
||||||
case querystring[cnt] of
|
cnt:=0;
|
||||||
'+': qunescaped[sptr] := ' ';
|
while cnt<=qslen do
|
||||||
'%': begin
|
begin
|
||||||
qunescaped[sptr] :=
|
case querystring[cnt] of
|
||||||
hexconv(querystring[cnt+1], querystring[cnt+2]);
|
'+': qunescaped[sptr] := ' ';
|
||||||
inc(cnt,2);
|
'%': begin
|
||||||
end;
|
qunescaped[sptr] :=
|
||||||
else
|
hexconv(querystring[cnt+1], querystring[cnt+2]);
|
||||||
qunescaped[sptr] := querystring[cnt];
|
inc(cnt,2); { <--- not allowed in for loops in pascal }
|
||||||
end;
|
end;
|
||||||
inc(sptr);
|
else
|
||||||
|
qunescaped[sptr] := querystring[cnt];
|
||||||
|
end;
|
||||||
|
inc(sptr);
|
||||||
{ skelet fix }
|
{ skelet fix }
|
||||||
qunescaped[sptr]:=#0;
|
qunescaped[sptr]:=#0;
|
||||||
end;
|
inc(cnt); { <-- don't forget to increment }
|
||||||
UnEscape:=qunescaped;
|
end;
|
||||||
|
UnEscape:=qunescaped;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function Chop(QunEscaped : PChar) : Longint;
|
Function Chop(QunEscaped : PChar) : Longint;
|
||||||
@ -482,7 +486,10 @@ end.
|
|||||||
{
|
{
|
||||||
HISTORY
|
HISTORY
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.7 2002-10-10 05:48:20 michael
|
Revision 1.8 2002-10-18 05:43:53 michael
|
||||||
|
+ Fix of invalid pointer bug in unescape, from U. Maeder
|
||||||
|
|
||||||
|
Revision 1.7 2002/10/10 05:48:20 michael
|
||||||
Added http_remote and fixed determining of input method. Fix courtesy of Antal <antal@carmelcomputer.com>
|
Added http_remote and fixed determining of input method. Fix courtesy of Antal <antal@carmelcomputer.com>
|
||||||
|
|
||||||
Revision 1.6 2002/09/12 16:24:59 michael
|
Revision 1.6 2002/09/12 16:24:59 michael
|
||||||
|
Loading…
Reference in New Issue
Block a user