OData / OData/AspNetCoreOData

Deserializing Escaped JSON Strings

Open
#67 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

followup
Dominant language
C#
Stars
505
Forks
186
PR merge metrics
No merged PRs in 30d

Description

One of my OData entities contains a field that holds HTML content as a string. So when I send a JSON request body, I have to escape double quotes and other special characters. However, OData is not deserializing these escaped JSON strings correctly. I have reproduced the issue in a minimal repository here.

POST /api/model

Request:

{
    "html": "<div class=\"test\"><\/div>"
}

Response:

{
    "Html": "<div class=\\\"test\\\"></div>"
}

Packages:
.NET Core 3.1
Microsoft.AspNetCore.OData 7.5.4
Microsoft.OData.Core 7.8.1
Microsoft.OData.Edm 7.8.1

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the POST /api/model reproduction in the linked minimal repository, using the listed Microsoft.AspNetCore.OData and Microsoft.OData package versions. Compare the submitted escaped HTML string with the response; the issue is done when the value round-trips without extra escaping, with a regression test if the repository provides a suitable test location.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.