odata.net
odata.net copied to clipboard
Escaped characters(\t) are not correctly deserialised in Odata7.x
In json, a tab character is specified like \\t
, and odata use to honor this and deserialize it as a \t
prior to the upgrade. After this upgrade, odata stopped honoring it and deserialized it as-is ( a literal \\t
, not an escaped \t
tab).
Assemblies affected
Issue was observed in After we upgraded to Web API OData 7.0.1 and OData.NET 7.5.1. from Odata 6.2 and WebAPI 5.9
Reproduce steps
Issue a PUT/POST with a request Body as shown below: { 'name' = 'abc'; 'dataSourceName' = 'xwz'; 'targetIndexName' = 'pqr'; 'parameters' = { 'configuration' = { 'delimitedTextDelimiter' = '\t' } } }
You will notice that the tab '\t' is treated as a String and deserialised as '\\t' when the request reached the controller.
Expected result
'\t' should be correctly deserialised. This worked as expected in Odata 6.2 and WebAPI 5.9
Actual result
Currently '\t' is deserialised as '\\t'. The behaviour might be same for other escaped characters as well.
Is this landing in 7.6? We have a few customers which are impacted by this bug.
@UD1412 I tested it in
- Asp.NET OData v5.9
- Asp.NET OData v7.1
- Asp.NET Core OData v7.1
Can't repo it in all above versions.
@xuzhg The issue only occurs for strings that are values of open properties. Please see our standalone repro here: https://github.com/brjohnstmsft/odata-repros/tree/master/EscapedTab
I've added a new version of the repro that includes our workarounds: https://github.com/brjohnstmsft/odata-repros/tree/master/EscapedTab/EscapedTabWorkaround
The workaround is here: https://github.com/brjohnstmsft/odata-repros/blob/e37bf0f236186102f36ae8f43c2bf401e37c1e1a/EscapedTab/EscapedTabWorkaround/Repro/Startup.cs#L25
Should default the ReadUntypedAsString to false in 8.x.
Either ReadUntypedAsString
should default to true or should be removed. Alternatively, we should just address the underlying tab character parsing issue.
This is specific to serializing untyped values as string.
Note: in 8.x, we should make ReadUntypedAsString=false
the default, and consider fixing writing of tabs if it is not too complex.