Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Comment: | replace unexpected use of Utf8ToUnicodeString() into correct SynCommons value - fix potential GPF in JSONToObject() when unserializing UnicodeString properties |
---|---|
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
f67ad3556eb4978fe148d9d8a9b9e9fc |
User & Date: | abouchez 2013-04-24 12:26:19 |
2013-04-25
| ||
13:58 | added TServiceInstanceImplementation.sicPerThread mode - feature request [cb76c866bb] check-in: 6308e26c35 user: abouchez tags: trunk | |
2013-04-24
| ||
12:26 | replace unexpected use of Utf8ToUnicodeString() into correct SynCommons value - fix potential GPF in JSONToObject() when unserializing UnicodeString properties check-in: f67ad3556e user: abouchez tags: trunk | |
12:23 | fixed UTF8ToWideChar() functions to always append a WideChar(0) to the end of the destination buffer, even if returned length is 0 check-in: df01125af9 user: abouchez tags: trunk | |
Changes to SQLite3/mORMot.pas.
12889 12890 12891 12892 12893 12894 12895 12896 12897 12898 12899 12900 12901 12902 12903 12904 12905 12906 12907 12908 12909 ..... 14277 14278 14279 14280 14281 14282 14283 14284 14285 14286 14287 14288 14289 14290 14291 ..... 16730 16731 16732 16733 16734 16735 16736 16737 16738 16739 16740 16741 16742 16743 16744 ..... 17209 17210 17211 17212 17213 17214 17215 17216 17217 17218 17219 17220 17221 17222 17223 ..... 27381 27382 27383 27384 27385 27386 27387 27388 27389 27390 27391 27392 27393 27394 27395 |
result := StrCompW(pointer(tmp1),pointer(tmp2)); end; end; function TSQLPropInfoRTTIUnicode.SetBinary(Instance: TObject; P: PAnsiChar): PAnsiChar; begin SetUnicodeStrProp(Instance,pointer(fPropInfo), UTF8ToUnicodeString(FromVarString(PByte(P)))); result := P; end; procedure TSQLPropInfoRTTIUnicode.SetValue(Instance: TObject; Value: PUTF8Char; wasString: boolean); begin SetUnicodeStrProp(Instance,pointer(fPropInfo),UTF8DecodeToUnicodeString(Value,0)); end; {$endif UNICODE} { TSQLPropInfoRTTIDynArray } ................................................................................ result := UTF8DecodeToRawUnicode(Get(Row,Field),0); end; function TSQLTable.GetWP(Row, Field: integer; Dest: PWideChar; MaxDestChars: cardinal): integer; var P: PUTF8Char; begin P := Get(Row,Field); result := UTF8ToWideChar(Dest,P,MaxDestChars,StrLen(P)) shr 1; // bytes div 2 end; function TSQLTable.LengthW(Row, Field: integer): integer; begin // nil -> fast calculate unicode length, without any memory allocation result := Utf8ToUnicodeLength(Get(Row,Field)); end; ................................................................................ SetFloatProp(Instance,Pointer(@self),PExtended(P)^); inc(P,sizeof(Extended)); end; {$ifdef FPC}tkAString,{$endif} tkLString: SetLongStrProp(Instance,pointer(@self),FromVarString(PB)); {$ifdef UNICODE} tkUString: SetUnicodeStrProp(Instance,pointer(@self),Utf8ToUnicodeString(FromVarString(PB))); {$endif} tkDynArray: P := GetDynArray(Instance).LoadFrom(P); {$ifdef PUBLISHRECORD} tkRecord: P := RecordLoad(GetFieldAddr(Instance)^,P,PropType^); {$endif} ................................................................................ SetFloatProp(Instance,pointer(@self),V); end; {$ifdef FPC}tkAString,{$endif} tkLString: SetLongStrValue(Instance,RawUTF8(Value)); {$ifdef UNICODE} tkUString: // fast UTF-8 decoding SetUnicodeStrProp(Instance,pointer(@self),UTF8DecodeToUnicodeString(Value,0)); {$endif} tkDynArray: GetDynArray(Instance).LoadFrom(pointer(BlobToTSQLRawBlob(Value))); {$ifdef PUBLISHRECORD} tkRecord: RecordLoad(GetFieldAddr(Instance)^,pointer(BlobToTSQLRawBlob(Value)),PropType^); {$endif} ................................................................................ if not wasString then exit else P^.SetLongStrValue(Value,RawUTF8(PropValue)); {$ifdef UNICODE} tkUString: if not wasString then exit else SetUnicodeStrProp(Value,pointer(P),UTF8DecodeToUnicodeString(PropValue,0)); {$endif} tkWString: if not wasString then exit else begin UTF8ToWideString(PropValue,StrLen(PropValue),WS); SetWideStrProp(Value,pointer(P),WS); end; |
| | | | | | |
12889 12890 12891 12892 12893 12894 12895 12896 12897 12898 12899 12900 12901 12902 12903 12904 12905 12906 12907 12908 12909 ..... 14277 14278 14279 14280 14281 14282 14283 14284 14285 14286 14287 14288 14289 14290 14291 ..... 16730 16731 16732 16733 16734 16735 16736 16737 16738 16739 16740 16741 16742 16743 16744 ..... 17209 17210 17211 17212 17213 17214 17215 17216 17217 17218 17219 17220 17221 17222 17223 ..... 27381 27382 27383 27384 27385 27386 27387 27388 27389 27390 27391 27392 27393 27394 27395 |
result := StrCompW(pointer(tmp1),pointer(tmp2)); end; end; function TSQLPropInfoRTTIUnicode.SetBinary(Instance: TObject; P: PAnsiChar): PAnsiChar; begin SetUnicodeStrProp(Instance,pointer(fPropInfo), UTF8DecodeToUnicodeString(FromVarString(PByte(P)))); result := P; end; procedure TSQLPropInfoRTTIUnicode.SetValue(Instance: TObject; Value: PUTF8Char; wasString: boolean); begin SetUnicodeStrProp(Instance,pointer(fPropInfo),UTF8DecodeToUnicodeString(Value,StrLen(Value))); end; {$endif UNICODE} { TSQLPropInfoRTTIDynArray } ................................................................................ result := UTF8DecodeToRawUnicode(Get(Row,Field),0); end; function TSQLTable.GetWP(Row, Field: integer; Dest: PWideChar; MaxDestChars: cardinal): integer; var P: PUTF8Char; begin P := Get(Row,Field); result := UTF8ToWideChar(Dest,P,MaxDestChars,0) shr 1; // bytes div 2 end; function TSQLTable.LengthW(Row, Field: integer): integer; begin // nil -> fast calculate unicode length, without any memory allocation result := Utf8ToUnicodeLength(Get(Row,Field)); end; ................................................................................ SetFloatProp(Instance,Pointer(@self),PExtended(P)^); inc(P,sizeof(Extended)); end; {$ifdef FPC}tkAString,{$endif} tkLString: SetLongStrProp(Instance,pointer(@self),FromVarString(PB)); {$ifdef UNICODE} tkUString: SetUnicodeStrProp(Instance,pointer(@self),UTF8DecodeToUnicodeString(FromVarString(PB))); {$endif} tkDynArray: P := GetDynArray(Instance).LoadFrom(P); {$ifdef PUBLISHRECORD} tkRecord: P := RecordLoad(GetFieldAddr(Instance)^,P,PropType^); {$endif} ................................................................................ SetFloatProp(Instance,pointer(@self),V); end; {$ifdef FPC}tkAString,{$endif} tkLString: SetLongStrValue(Instance,RawUTF8(Value)); {$ifdef UNICODE} tkUString: // fast UTF-8 decoding SetUnicodeStrProp(Instance,pointer(@self),UTF8DecodeToUnicodeString(Value,StrLen(Value))); {$endif} tkDynArray: GetDynArray(Instance).LoadFrom(pointer(BlobToTSQLRawBlob(Value))); {$ifdef PUBLISHRECORD} tkRecord: RecordLoad(GetFieldAddr(Instance)^,pointer(BlobToTSQLRawBlob(Value)),PropType^); {$endif} ................................................................................ if not wasString then exit else P^.SetLongStrValue(Value,RawUTF8(PropValue)); {$ifdef UNICODE} tkUString: if not wasString then exit else SetUnicodeStrProp(Value,pointer(P),UTF8DecodeToUnicodeString(PropValue,StrLen(PropValue))); {$endif} tkWString: if not wasString then exit else begin UTF8ToWideString(PropValue,StrLen(PropValue),WS); SetWideStrProp(Value,pointer(P),WS); end; |