Fix issue #1000: export tables - sql syntax error. Escape null characters so they don't cut a string somewhere after escChars was called.

This commit is contained in:
Ansgar Becker
2009-02-18 19:42:01 +00:00
parent 694f3f15fd
commit edc2d538d3

View File

@ -1540,8 +1540,10 @@ const
block: Cardinal = 65536; block: Cardinal = 65536;
NLold1 = #13; NLold1 = #13;
NLold2 = #10; NLold2 = #10;
NullOld = #0;
NLnew1 = 'r'; NLnew1 = 'r';
NLnew2 = 'n'; NLnew2 = 'n';
NullNew = '0';
var var
bstart, bend, matches, i: Cardinal; bstart, bend, matches, i: Cardinal;
// These could be bumped to uint64 if necessary. // These could be bumped to uint64 if necessary.
@ -1562,7 +1564,8 @@ begin
(Text[i] = Char3) or (Text[i] = Char3) or
(Text[i] = Char4) or (Text[i] = Char4) or
(Text[i] = NLold1) or (Text[i] = NLold1) or
(Text[i] = NLold2) (Text[i] = NLold2) or
(Text[i] = NullOld)
then Inc(matches); then Inc(matches);
SetLength(Result, bend + 1 - bstart + matches + respos); SetLength(Result, bend + 1 - bstart + matches + respos);
for i := bstart to bend do begin for i := bstart to bend do begin
@ -1573,7 +1576,8 @@ begin
(Text[i] = Char3) or (Text[i] = Char3) or
(Text[i] = Char4) or (Text[i] = Char4) or
(Text[i] = NLold1) or (Text[i] = NLold1) or
(Text[i] = NLold2) (Text[i] = NLold2) or
(Text[i] = NullOld)
then begin then begin
Result[respos] := EscChar; Result[respos] := EscChar;
Inc(respos); Inc(respos);
@ -1584,6 +1588,9 @@ begin
end else if Text[i] = NLold2 then begin end else if Text[i] = NLold2 then begin
Result[respos] := NLnew2; Result[respos] := NLnew2;
continue; continue;
end else if Text[i] = NullOld then begin
Result[respos] := NullNew;
continue;
end; end;
end; end;
Result[respos] := Text[i]; Result[respos] := Text[i];