From d59b9250ff46c928cbbf53186b2a4b06b06239d4 Mon Sep 17 00:00:00 2001 From: skalogryz Date: Sat, 16 Jan 2016 06:48:25 +0000 Subject: [PATCH] iphonelazext: added unescaping of PBX properties values during parsing. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4426 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/iphonelazext/pbx/pbxfile.pas | 41 +++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/components/iphonelazext/pbx/pbxfile.pas b/components/iphonelazext/pbx/pbxfile.pas index 39037ae83..bb17540ea 100644 --- a/components/iphonelazext/pbx/pbxfile.pas +++ b/components/iphonelazext/pbx/pbxfile.pas @@ -157,6 +157,8 @@ procedure ParseAString(const test: string); function PBXParserSkipLevel(p: TPBXParser): Boolean; function PBXRawWriteValue(const v: string): string; +function Unescape(const s: string): string; + implementation type @@ -173,6 +175,44 @@ const ToEscape = ['"',#13,#9,#10,'\']; // commas are not +function Unescape(const s: string): string; +var + i : Integer; + j : Integer; + cnt : Integer; +begin + if s='' then begin + Result:=''; + Exit; + end; + SetLength(Result, length(s)); + cnt := length(s); + i:=1; + j:=1; + while i<=cnt do begin + if s[i]='\' then begin + inc(i); + if i<=cnt then begin + case s[i] of + 'r': Result[j]:=#10; + 'n': Result[j]:=#13; + 't': Result[j]:=#9; + '0': Result[j]:=#0; + else + Result[j]:=s[i]; + end; + inc(j); + inc(i); + end; + end else begin + Result[j]:=s[i]; + inc(j); + inc(i); + end; + end; + Result:=Copy(Result, 1, j-1); +end; + function PBXRawWriteValue(const v: string): string; var i : Integer; @@ -602,6 +642,7 @@ begin inc(idx); end; until donestr; + FCurTokenString:=Unescape(FCurTokenString); inc(idx); end; '=': begin