Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 7 of 7 total
Thread TWriter/TReader oopsie
Wed, Apr 6 2016 11:18 AMPermanent Link

Matthew Jones

Using the TWriter to serialise properties, it incorrectly quotes the
strings in properties. If I type in the line:

Hello " Mum

Then it appears in the JSON as:

"propertyname": "Hello "" Mum",

It should be:
"propertyname": "Hello \" Mum",


When read back in, the TReader barfs on this.

The problem appears to be here:

procedure TWriter.StringValue(const Value: String);
begin
  Append(QuotedStr(Value,DOUBLE_QUOTE));
end;

I was going to say that should be BACKSLASH, but the QuotedStr doesn't
look for one and prefix another, so bigger issue to code around than a
single change.

--

Matthew Jones
Thu, Apr 7 2016 4:53 AMPermanent Link

Matthew Jones

Matthew Jones wrote:

> The problem appears to be here:
>
> procedure TWriter.StringValue(const Value: String);
> begin
>    Append(QuotedStr(Value,DOUBLE_QUOTE));
> end;
>
> I was going to say that should be BACKSLASH, but the QuotedStr doesn't
> look for one and prefix another, so bigger issue to code around than a
> single change.


Another offline thought - this must already exist - and it does. It
should be calling "EscapeStr" and not "QuotedStr" here.

--

Matthew Jones
Thu, Apr 7 2016 7:47 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Matthew,

<< Another offline thought - this must already exist - and it does. It should be calling "EscapeStr" and not "QuotedStr" here. >>

Got it, thanks.

Tim Young
Elevate Software
www.elevatesoft.com
Thu, Apr 7 2016 8:09 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Matthew,

Actually, after looking at this - it should be calling *both*.

Tim Young
Elevate Software
www.elevatesoft.com
Thu, Apr 7 2016 8:13 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Matthew,

Nix that, it should look like this:

procedure TWriter.StringValue(const Value: String);
begin
  Append(DOUBLE_QUOTE+EscapeStr(Value)+DOUBLE_QUOTE);
end;

Tim Young
Elevate Software
www.elevatesoft.com
Thu, Apr 7 2016 2:29 PMPermanent Link

Matthew Jones

Tim Young [Elevate Software] <timyoung@elevatesoft.com> wrote:
> Matthew,
>
> Actually, after looking at this - it should be calling *both*.
>


I hacked mine to build up an escaped string with double quotes. I don't
think it should double up the quotes as well as escaping. I'm sure you know
this though.

--
Matthew Jones
Thu, Apr 7 2016 2:29 PMPermanent Link

Matthew Jones

Tim Young [Elevate Software] <timyoung@elevatesoft.com> wrote:
> Matthew,
>
> Nix that, it should look like this:
>
> procedure TWriter.StringValue(const Value: String);
> begin
>    Append(DOUBLE_QUOTE+EscapeStr(Value)+DOUBLE_QUOTE);
> end;
>
>

I should read fully. You match mine.

--
Matthew Jones
Image