Skip to content

Clarify SEB-JSON encoding on developer Config Key page - #25

Open
cameron1729 wants to merge 1 commit into
SafeExamBrowser:masterfrom
cameron1729:improve-seb-json-docs
Open

Clarify SEB-JSON encoding on developer Config Key page#25
cameron1729 wants to merge 1 commit into
SafeExamBrowser:masterfrom
cameron1729:improve-seb-json-docs

Conversation

@cameron1729

@cameron1729 cameron1729 commented Jul 11, 2026

Copy link
Copy Markdown

Summary

This PR adds a stable, directly linkable SEB-JSON section to the developer Config Key documentation. It:

  • Defines SEB-JSON separately from the other Config Key preparation steps
  • Clarifies that SEB-JSON is JSON-ish but is not necessarily valid standard JSON
  • Explains that string contents are written without standard JSON character escaping
  • Adds small examples showing how quotation marks and backslashes differ from standard JSON
  • Links to 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
  • Corrects several typographical and wording errors in the existing documentation
  • Adds a stable #seb-json anchor which other projects can reference

Why 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:

  • Moodle, the world's most widely used open source LMS, uses PHP's json_encode in 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.
  • certible/seb-node explicitly recognises that the specification says not to escape strings, but uses JSON.stringify because it considers valid JSON necessary. Dictionary keys are escaped in the same way.
  • Chiogros/nSEA uses Python's json.dumps and then removes spaces from the completed serialised value. In addition to standard JSON escaping, this can remove spaces from actual setting values.
  • This Node.js implementation guide treats SEB-JSON as compact standard JSON and uses 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:

  1. Create a dedicated SEB-JSON encoder based on the behaviour of the official Windows and macOS algorithms
  2. Verify it continuously against source from SEB releases
  3. Clarify the official SEB-JSON documentation through this PR
  4. Update Moodle to consume the package instead of maintaining its own encoding workaround

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant