From edc2d538d3e09cb1988dcf62e6b09534e342201c Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Wed, 18 Feb 2009 19:42:01 +0000 Subject: [PATCH] Fix issue #1000: export tables - sql syntax error. Escape null characters so they don't cut a string somewhere after escChars was called. --- source/helpers.pas | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/source/helpers.pas b/source/helpers.pas index e0f1528f..45ef5544 100644 --- a/source/helpers.pas +++ b/source/helpers.pas @@ -1540,8 +1540,10 @@ const block: Cardinal = 65536; NLold1 = #13; NLold2 = #10; + NullOld = #0; NLnew1 = 'r'; NLnew2 = 'n'; + NullNew = '0'; var bstart, bend, matches, i: Cardinal; // These could be bumped to uint64 if necessary. @@ -1562,7 +1564,8 @@ begin (Text[i] = Char3) or (Text[i] = Char4) or (Text[i] = NLold1) or - (Text[i] = NLold2) + (Text[i] = NLold2) or + (Text[i] = NullOld) then Inc(matches); SetLength(Result, bend + 1 - bstart + matches + respos); for i := bstart to bend do begin @@ -1573,7 +1576,8 @@ begin (Text[i] = Char3) or (Text[i] = Char4) or (Text[i] = NLold1) or - (Text[i] = NLold2) + (Text[i] = NLold2) or + (Text[i] = NullOld) then begin Result[respos] := EscChar; Inc(respos); @@ -1584,6 +1588,9 @@ begin end else if Text[i] = NLold2 then begin Result[respos] := NLnew2; continue; + end else if Text[i] = NullOld then begin + Result[respos] := NullNew; + continue; end; end; Result[respos] := Text[i];