Azure / Azure/durabletask

Unicode characters should be escape when serializing messages.

Open
#1,188 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
1.7k
Forks
335
Avg merge
2d 23h
Merged PRs (30d)
6

Description

https://github.com/Azure/durabletask/blob/3bc255cb4df1565e5ac760ebd1dc040f58f02e5e/src/DurableTask.Core/Serializing/JsonDataConverter.cs#L38

Add `StringEscapeHandling = StringEscapeHandling.EscapeNonAscii` into JsonSerializerSettings.

```
public JsonDataConverter()
: this(new JsonSerializerSettings
{
TypeNameHandling = TypeNameHandling.Objects,
DateParseHandling = DateParseHandling.None,
StringEscapeHandling = StringEscapeHandling.EscapeNonAscii,
#if NETSTANDARD2_0
SerializationBinder = new PackageUpgradeSerializationBinder()
#else
Binder = new PackageUpgradeSerializationBinder()
#endif
})
{ }
```
When using the `Microsoft.DurableTask.SqlServer` package, the Payloads field's datatype is varchar(max).
When the database defaults to English, so varchar will not be saved correctly when inserting Unicode characters.

Example:

```
SELECT [Text],[Reason] FROM [dt].[Payloads]

[{"$type":"xxx","Name":"????2024?4??????.md","BookId":"6b88bc7a-9c5f-7a83-2003-e935bb5b33a8","BookName":"????2024?4??????.md"}]
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.