dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.4k stars 10k forks source link

[JsonPatch]: PathHelpers.NormalizePath should allow spaces and \\ characters #2876

Closed pranavkm closed 6 years ago

pranavkm commented 6 years ago

Consider

public class Person
{
    [JsonProperty("Person Name")]
    public string Name { get; set; }
}

A patch can be sucessfully applied to this property as

var doc = new JsonPatchDocument
{
    Operations = 
    {
        new Operation("add", "/Person Name", null, "New Name"),
    },
};

doc.ApplyTo(person); // This works correctly.
doc.Add("Person Name", "New Name") fails

Same deal with back slashes. The invalid char check in that method is kinda unncecessary.

mkArtakMSFT commented 6 years ago

@ajaybhargavb, can you please look into this? Thanks!

ajaybhargavb commented 6 years ago

Yup. The spec https://tools.ietf.org/html/rfc6901 does not disallow whitespace or backslashes. I'll send a PR.

ajaybhargavb commented 6 years ago

aspnet/JsonPatch@63f03228106c61b6af2965c874f09758f7a5439e