Clarify SEB-JSON encoding on developer Config Key page - #25
Open
cameron1729 wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a stable, directly linkable SEB-JSON section to the developer Config Key documentation. It:
cameron1729/seb-json, the only known publicly available SEB-JSON encoder whose output is automatically verified against the official SEB for Windows and macOS implementations#seb-jsonanchor which other projects can referenceWhy this is needed
This work began with MDL-78086. The original intention was to fix SEB-JSON generation directly in Moodle.
However, studying the official Windows and macOS source revealed that the problem was broader than Moodle. SEB-JSON deliberately has different string semantics from standard JSON. Standard JSON encoders are designed to escape strings and produce valid JSON, so attempting to adapt their output to SEB-JSON tends to result in incomplete workarounds.
Several independent implementations illustrate the resulting confusion:
json_encodein v5.2.1 with unescaped slashes and Unicode, together with a placeholder workaround for backslashes. Quotation marks and control characters are still escaped according to standard JSON rules.JSON.stringifybecause it considers valid JSON necessary. Dictionary keys are escaped in the same way.json.dumpsand then removes spaces from the completed serialised value. In addition to standard JSON escaping, this can remove spaces from actual setting values.JSON.stringify. It also removes a space from the completed serialised string, which can alter a setting value.There are also multiple discussions in which developers have been unable to reproduce Config Keys after following the existing documentation:
These examples are not included to criticise their authors. They demonstrate that treating SEB-JSON as ordinary JSON is a reasonable conclusion to draw from the existing documentation, even though it produces different bytes from the official SEB implementations. They also demonstrate the need for a reusable encoder whose output is continuously verified against those implementations, rather than requiring every integration to reproduce SEB-JSON independently.
Background and intended follow-up
While investigating MDL-78086, it became clear that adding another Moodle-specific workaround would fix only one implementation and leave the underlying ecosystem problem unresolved.
The resulting approach is:
The first two steps resulted in
cameron1729/seb-json, a deliberately small PHP encoder which is also available through Composer. It is the only known publicly available SEB-JSON encoder whose output is automatically verified against the official Windows and macOS implementations.If this PR is accepted, the package documentation will be updated to link directly to the new canonical SEB-JSON section. MDL-78086 will then be updated to replace Moodle's current implementation with the package.