#1 2015-07-18 15:19:18

ASiwon
Member
From: Poland
Registered: 2015-01-30
Posts: 82

Unexpected TInterfaceStub behaviour

Hello,

today I have upgraded mormot from version from 29th April to the newest. After change I found unexpected change in creation of stubs for interfaces with RawByteString properties. Earlier stub was prepared using following code:

  cPassword: RawUTF8 = 'hasloPlain';
  cPasswordEncoded: RawByteString = 'hasloEncoded';

  TInterfaceStub.Create(TypeInfo(IGxPasswordCoder), coder).
    Returns('Encode', [cPassword], [cPasswordEncoded]);

and stub works correctly. After upgrading, stub after calling Encode function returns wrong value. Only when preparation code is changed to:

  TInterfaceStub.Create(TypeInfo(IGxPasswordCoder), coder).
    Returns('Encode', [cPassword], [BinToBase64(cPasswordEncoded)]);

then everything works correctly. I just want to know: Is it intentional change in mORMot and must I change all my stubs definitions?

Last edited by ASiwon (2015-07-18 15:20:05)


best regards
Adam Siwon

Offline

#2 2015-07-18 18:40:35

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

Re: Unexpected TInterfaceStub behaviour

I suspect this comes from the fact that RawByteString are now encoded as Base64, when serialized as JSON.
Previous behavior was not correct, since any #0 char within the RawByteString may have broken the process.
It also allows to send arbitrary binary data from interface-based services to (web) clients, in a standard way.

I think the new pattern is more correct.
Your cPasswordEncoded should be serialized as Base64 string, in the JSON content.

Offline

Board footer

Powered by FluxBB