#1 2021-08-18 20:07:58

Eugene Ilyin
Member
From: milky_way/orion_arm/sun/earth
Registered: 2016-03-27
Posts: 132
Website

[Fixed] CSVToRawUTF8DynArray

Hi, the recent 1.18.6309:

Check
program Test;
{$APPTYPE CONSOLE}
uses
  SynCommons;
var
  R1, R2: TRawUTF8DynArray;
begin
  CSVToRawUTF8DynArray('AA,BB,CC,DD', ',', ',', R1);
  CSVToRawUTF8DynArray('A,B,C,D', ',', ',', R2);
  Writeln(RawUTF8ArrayToCSV(R1));
  Writeln(RawUTF8ArrayToCSV(R2));
  Readln;
end.
Expected
AA,BB,CC,DD
A,B,C,D
Actual
AA,BB,CC,DD
A,B,C
Issue

RawUTF8ArrayToCSV problem place:

Actual:
  while offs<length(CSV) do begin

Expected:
  while offs<=length(CSV) do begin
Impact

SynECC.pas:
  TECDHEProtocol.FromKey
    CSVToRawUTF8DynArray(c,',','',chain);

mORMot.pas:
  TSQLRecordPropertiesMapping.InternalCSVToExternalCSV
    CSVToRawUTF8DynArray(CSVFieldNames,Sep,SepEnd,IntFields);

Coverage

The SynSelfTests.pas TTestLowLevelCommon._UTF8 doesn't cover the listed case:

  CSVToRawUTF8DynArray(res,',','',arr);
  Check(arr[0]='one');
  Check(arr[1]='two');
  Check(arr[2]='three');
  Finalize(arr);
  CSVToRawUTF8DynArray('one=?,two=?,three=?','=?,','=?',arr);
  Check(arr[0]='one');
  Check(arr[1]='two');
  Check(arr[2]='three');
  Finalize(arr);

Last edited by Eugene Ilyin (2021-08-19 11:29:18)

Offline

#2 2021-08-19 06:12:30

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: [Fixed] CSVToRawUTF8DynArray

I have now fixed CsvToRawUtf8DynArray() for both mORMot 1 and mORMot 2.
With new regression tests.

Thanks Eugene for the feedback!

Offline

#3 2021-08-19 11:28:57

Eugene Ilyin
Member
From: milky_way/orion_arm/sun/earth
Registered: 2016-03-27
Posts: 132
Website

Re: [Fixed] CSVToRawUTF8DynArray

Fix confirmed, thanks!

Offline

Board footer

Powered by FluxBB