Skip to content

feat: Fable-generated port into Elixir - #2

Draft
s3cur3 wants to merge 1 commit into
mainfrom
elixir-rewrite
Draft

s3cur3 wants to merge 1 commit into
mainfrom
elixir-rewrite

Conversation

@s3cur3

@s3cur3 s3cur3 commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

I asked Fable to rewrite the C library in Elixir, starting with porting the complete test suite from the upstream project. This is what it came up with.

Here's what it did:

  1. Renamed the NIF to Libwbxml.Native
  2. Vendored all 221 upstream test documents under test/fixtures/upstream/. The upstream round-trip harness and its Perl normaliser were ported and verified against the C tools. 3. Token tables for all 29 languages were generated from the C source rather than transcribed. The codec is four modules: reader.ex (XML to tree via xmerl), encoder.ex, parser.ex, and writer.ex, on top of Error, Charset, Base64, Tree, Opaque and Tables. All 1292 golden binary tests match byte for byte in both directions. The upstream round-trips pass through Elixir. With the NIF still present, 6650 fuzz mutations agreed with C.
  3. Deleted vendor/, native/, the Makefile, checksum, release workflow, the NIF loader, and the helper scripts. Bumped mix.exs version, updated README.md, CHANGELOG.md, LICENSE and NOTICE.

It made note of a number of points of weirdness it discovered in the upstream binary (noted with NOTE(upstream-quirk) comments in the code)—one of which was a null pointer dereference which would bring down the whole BEAM (!).

Do we want to ship this? I don't know. The fact that it's byte-identical with C makes me think it might actually be okay.

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