Problem/Motivation
The JSON API spec lists the invalid characters for member names at http://jsonapi.org/format/#document-member-names
This list includes the "Reverse Solidus" (a.k.a. backslash) as an invalid character, but the symbol printed in the docs on that line is some type of double-quote, not the backslash. As a result, the validation function and tests include the wrong character in their list of invalid characters.
This validation also doesn't check against ASCII control characters (Unicode 0x00-0x1F).
Proposed resolution
Fix this by replacing the incorrect character with a backslash character. Also add checks against ASCII control characters.
Comments
Comment #2
hampercm commentedComment #3
dawehnerI looked out for some other implementation of this. Observations: a) there are a couple of people who have installed the jsonapi module in the wild. b) Some implementation know about the standard but then fail quite a bit: https://github.com/erickt/jsonapi/blob/1ebd4e4bc8ff6302eb8a499aaceb6ef72... https://github.com/automatonic/japi/blob/7249d06007a327f935982f21ad02aee... https://github.com/trailblazer/roar-jsonapi/blob/adfc2ac4f6c4361c519efa7... https://github.com/UpstateRuby/openworks-status-api/blob/88a4fe948d38a61...
We should ideally document this particular line by maybe moving the reference to the reference from the test over here to the implementation.
Comment #4
hampercm commentedThe reference to the official standard is added to this class by #2844373: Address core feedback 2843147#comment-11872253
Comment #5
dawehnerI tried to write a regex or so to produce the same kind of value, but I couldn't. I'm glad we have test coverage now!
Comment #7
e0ipsoThis looks great! Merging.
Comment #8
e0ipsoComment #9
wim leersAlso see #2829328-12: Clean up Drupal\jsonapi\Access\CustomParameterNames and make it follow the spec more closely, which further expands this.