Jump to content
iddqd345

Escaping characters in HttpRest.RestParams.AdditemSO

Recommended Posts

Hi,


I need to send the following line in the request:

S := 'aaa'+#29+'bbb'

If I do this

soNode.AsArray.s[0] := S;
HttpRest.RestParams.AdditemSO('codes',soNode);

then it is sent as
'aaa~bbb'


If I escape myself:

S := 'aaa\u001dbbb';

then the result:
'aaa\\u001dbbb'


This is a strange result. Why does this happen?

In TRestParams.AddItemSO, escaping when getting from ISuperObject is disabled:

        Items[Index].PValue := aValue.AsJson(false,false) { no indent, no escape }

At the same time, in RestRequest:

EncParams := AnsiString(IcsStrRemCntlsA(EncParams));

where "Source^ < IcsSpace" replaced with '~'.


Yes, I found a solution:

HttpRest.RestParams.AddItem('codes', soNode.AsJSon(False,true),True);

but it doesn't look very logical when using SuperObject


I don't understand the logic of not full escaping when using AddItemSO.

In this case, when escape=False, in TSuperObject.Write DoMinimalEscape is executed instead of DoEscape, which escapes '\', but does not escape char < #32
Perhaps this is a mistake?

Share this post


Link to post

Sorry, no quick answer. 

 

The issue here is avoiding multiple escaping with nested escaped objects. which is why some AddItem overloads have an ARaw parameter to skip escaping, but not AddItemSO. 

 

I'll need to look carefully at this so as not to break anything, mat be a while.

 

Angus

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×