Skip to content

Use byte widths for fixed-record MIME databases - #65

Closed
OskarEichler wants to merge 1 commit into
discourse:mainfrom
OskarEichler:codex/mini-mime-byte-widths
Closed

Use byte widths for fixed-record MIME databases#65
OskarEichler wants to merge 1 commit into
discourse:mainfrom
OskarEichler:codex/mini-mime-byte-widths

Conversation

@OskarEichler

Copy link
Copy Markdown

Summary

Measure database row sizes and generated column padding in bytes. Positional reads use byte offsets, but String#length counts characters; custom Unicode extensions could make later records unreadable.

Reproduction

Write a UTF-8 custom extension database with these equal-byte-width rows:

é text/one 7bit
ê text/two 7bit

RandomAccessDb.new(path, 0).lookup('ê') returned nil. It now returns text/two. Three focused lookup/miss assertions pass with native pread and again with the fallback seek/read implementation selected in a disposable process. A generator check confirms mixed ASCII/Unicode columns produce equal byte widths. No database regeneration is included.

Verification

  • Ruby 4.0.6 via rbenv: eight existing core tests / 22 assertions pass, before and after.
  • Existing optional mime-types parity test: nine tests / one pre-existing error on both baseline and patch (newer reference-data extensions absent from the bundled snapshot). No data refresh or test changes.
  • Full RuboCop: one pre-existing redundant-disable offense on main and each patch, no additions. Ruby syntax and git diff --check pass.
  • No repository tests added/modified under the commissioning repository’s explicit policy; focused checks run externally. Other Ruby versions/platforms were not run locally.

Compatibility

No intended breaking change. ASCII database bytes and lookup results are unchanged; Unicode custom databases must use fixed byte widths, as required by positional reads. The fallback check is simulated on macOS, not a Windows CI claim.

@ZogStriP
ZogStriP requested a review from SamSaffron September 1, 2026 15:52
@SamSaffron SamSaffron mentioned this pull request Sep 2, 2026
SamSaffron added a commit that referenced this pull request Sep 2, 2026
Require Ruby 3.3 and refresh the bundled MIME database from
mime-types-data 3.2026.0701. Use byte offsets for Unicode-safe database
lookups, avoid duplicate lowercase misses, and preserve extension
priorities when rebuilding the database.

Update CI to cover current Ruby implementations and runners.

closes #64, #65, #66
@SamSaffron

Copy link
Copy Markdown
Member

sorry addressed in my big pr

@SamSaffron SamSaffron closed this Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants