#1 2016-12-29 17:44:48

itSDS
Member
From: Germany
Registered: 2014-04-24
Posts: 516

Bug in mormot.pas, calling mvc view default

Hi i get error Message calling mvc view with latest version.

The error seem to be in mormot.pas:

function TSQLRestServerURIContext.GetInputAsTDocVariant: variant;

i replaced the function with former one and the mvc works as expected.

the Error is that

fInput in this call has the Value 'null' and not ''
mormotmvc - line 1484

              if not exec.ExecuteJson([fApplication.fFactoryEntry],pointer(fInput),WR,true) then

the null is calculated with actual version of GetInputasTDocVariant.

here the older working funktion:

function TSQLRestServerURIContext.GetInputAsTDocVariant: variant;
var ndx: integer;
    v: variant;
    MultiPart: TMultiPartDynArray;
begin
  VarClear(result);
  FillInput;
  if fInput<>nil then begin
    with TDocVariantData(result) do begin
      InitFast;
      for ndx := 0 to (length(fInput) shr 1)-1 do begin
        GetVariantFromJSON(pointer(fInput[ndx*2+1]),false,v,@JSON_OPTIONS[true]);
        AddValue(fInput[ndx*2],v);
      end;
    end;
  end else
  if InputAsMultiPart(MultiPart) then
    with TDocVariantData(result) do begin
      InitFast;
      for ndx := 0 to high(MultiPart) do
        with MultiPart[ndx] do
          if ContentType=TEXT_CONTENT_TYPE then begin
            // append as regular "Name":"TextValue" field
            RawUTF8ToVariant(Content,v);
            AddValue(Name,v);
          end else
            // append binary file as an object, with Base64-encoded data
            AddValue(Name,_ObjFast(['data',BinToBase64(Content),
              'filename',FileName,'contenttype',ContentType]));
    end;
end;

Rad Studio 12.1 Santorini

Offline

#2 2016-12-29 17:48:31

itSDS
Member
From: Germany
Registered: 2014-04-24
Posts: 516

Re: Bug in mormot.pas, calling mvc view default

In new function the call to res.InitFast fills Result with 'null'


Rad Studio 12.1 Santorini

Offline

#3 2016-12-29 17:49:34

itSDS
Member
From: Germany
Registered: 2014-04-24
Posts: 516

Re: Bug in mormot.pas, calling mvc view default

Calling
exec.ExecuteJson([fApplication.fFactoryEntry],pointer(fInput),WR,true)
with fInput set to 'null' Excepts with wrong Parameter


Rad Studio 12.1 Santorini

Offline

#4 2016-12-29 17:55:13

itSDS
Member
From: Germany
Registered: 2014-04-24
Posts: 516

Re: Bug in mormot.pas, calling mvc view default

I modfied the actual Version that it works. The Call to InitFast was executed if fInput = nil in former this was only if FInput neq nil

function TSQLRestServerURIContext.GetInputAsTDocVariant: variant;
var ndx: integer;
    v: variant;
    MultiPart: TMultiPartDynArray;
    res: TDocVariantData absolute result;
begin
  VarClear(result);
  FillInput;
  if fInput<>nil then begin
    res.InitFast;
    for ndx := 0 to (length(fInput) shr 1)-1 do begin
      GetVariantFromJSON(pointer(fInput[ndx*2+1]),false,v,@JSON_OPTIONS[true]);
      res.AddValue(fInput[ndx*2],v);
    end
  end else
  if InputAsMultiPart(MultiPart) then begin
    res.InitFast;
    for ndx := 0 to high(MultiPart) do
      with MultiPart[ndx] do
        if ContentType=TEXT_CONTENT_TYPE then begin
          // append as regular "Name":"TextValue" field
          RawUTF8ToVariant(Content,v);
          res.AddValue(Name,v);
        end else
          // append binary file as an object, with Base64-encoded data
          res.AddValue(Name,_ObjFast(['data',BinToBase64(Content),
            'filename',FileName,'contenttype',ContentType]));
  end;
end;

Rad Studio 12.1 Santorini

Offline

#5 2017-01-03 18:16:25

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

Re: Bug in mormot.pas, calling mvc view default

You are right.

Should be fixed by http://synopse.info/fossil/info/8380e41113

Sorry for the regression.

Online

Board footer

Powered by FluxBB