aspnet / JsonPatch

[Archived] JSON PATCH library. Project moved to https://github.com/aspnet/AspNetCore
Apache License 2.0
103 stars 48 forks source link

Paths containing '.' trigger JsonPatchException #124

Closed arerlend closed 6 years ago

arerlend commented 6 years ago

In /src/Microsoft.AspNetCore.JsonPatch/Internal/PathHelpers.cs:

if (path.Contains(".") || path.Contains("//") || path.Contains(" ") || path.Contains("\\")) { throw new JsonPatchException(Resources.FormatInvalidValueForPath(path), null); }

The spec at jsonpatch.com doesn't ever specify that '.' characters are invalid or must be escaped.

Eilon commented 6 years ago

Yeah this just looks like a plain old bug. The JSON PATCH RFC Section 4 (https://tools.ietf.org/html/rfc6902#section-4) points at https://tools.ietf.org/html/rfc6901 to define allowed JSON paths, and I don't see any reason to disallow the . character.

Eilon commented 6 years ago

@jbagga there's already a PR for this, so I'm assigning this bug to you to review & merge.

arerlend commented 6 years ago

That's a far better spec. Didn't realize it existed... TIL

rynowak commented 6 years ago

Fixed by 70c8133 - thanks!