odata.net icon indicating copy to clipboard operation
odata.net copied to clipboard

Escaped characters(\t) are not correctly deserialised in Odata7.x

Open UD1412 opened this issue 6 years ago • 8 comments

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.

UD1412 avatar Jan 04 '19 21:01 UD1412

Is this landing in 7.6? We have a few customers which are impacted by this bug.

UD1412 avatar Feb 13 '19 20:02 UD1412

@UD1412 I tested it in

  1. Asp.NET OData v5.9
  2. Asp.NET OData v7.1
  3. Asp.NET Core OData v7.1

Can't repo it in all above versions.

xuzhg avatar Feb 15 '19 00:02 xuzhg

@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

brjohnstmsft avatar Feb 20 '19 22:02 brjohnstmsft

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

brjohnstmsft avatar Feb 28 '19 22:02 brjohnstmsft

Should default the ReadUntypedAsString to false in 8.x.

raheph avatar Jun 12 '19 20:06 raheph

Either ReadUntypedAsString should default to true or should be removed. Alternatively, we should just address the underlying tab character parsing issue.

corranrogue9 avatar Apr 27 '22 00:04 corranrogue9

This is specific to serializing untyped values as string.

corranrogue9 avatar May 09 '22 15:05 corranrogue9

Note: in 8.x, we should make ReadUntypedAsString=false the default, and consider fixing writing of tabs if it is not too complex.

mikepizzo avatar Jan 23 '24 19:01 mikepizzo