Skip to content

wpt: decode non-UTF-8 test files honouring BOM and declared encoding - #659

Open
nicoburns wants to merge 1 commit into
mainfrom
devin/1786204348-wpt-decode-non-utf8
Open

wpt: decode non-UTF-8 test files honouring BOM and declared encoding#659
nicoburns wants to merge 1 commit into
mainfrom
devin/1786204348-wpt-decode-non-utf8

Conversation

@nicoburns

@nicoburns nicoburns commented Aug 8, 2026

Copy link
Copy Markdown
Member

Summary

The runner crashed with stream did not contain valid UTF-8 on 11 css tests encoded as UTF-16 or a legacy encoding (css/CSS2/i18n/syndata/character-encoding-*.xht, css/css-syntax/charset/page-utf16-*.html), because process_test_file used fs::read_to_string(...).unwrap().

Test files are now read as bytes and decoded via decode_file_bytes:

  1. BOM (via encoding_rs::Encoding::for_bom) wins;
  2. otherwise valid UTF-8 is used as-is;
  3. otherwise the first 1024 bytes are scanned for a declared encoding (encoding=/charset= in an XML declaration, <meta charset>, or @charset), with a windows-1252 fallback. A declared UTF-16 label maps to UTF-8, per the HTML spec's "get an encoding" algorithm (an ASCII-readable declaration means the content isn't UTF-16).

WPT crash counts for css/CSS2/i18n/syndata + css/css-syntax/charset: 11 CRASH before, 0 after (all now run/skip normally).

Note: 4 tests flip PASS→FAIL with this change (font-family-invalid-characters-001/003.xht, text-emphasis-style-none-001.xht, text-transform-none-001.xht). These files have a UTF-8 BOM which was previously left in the parser input, corrupting parsing so their stylesheets never applied and they trivially matched their (unstyled) refs. With the BOM correctly stripped they actually exercise their styles and expose a separate engine issue: text consisting only of digits is not rendered when the font-family stack contains only unknown families (e.g. font-family: test) — letters fall back correctly but digits disappear.

Link to Devin session: https://dioxus.staging.devinenterprise.com/sessions/f1a0d6696eaa4076a48f366a24bfd26f
Requested by: @nicoburns

WPT results

0 newly passing, 4 newly failing (net -4), 11 other status changes.

Full diff (15 changed tests)
- Pass => Fail css/CSS2/fonts/font-family-invalid-characters-001.xht
- Pass => Fail css/CSS2/fonts/font-family-invalid-characters-003.xht
! Crash => Skip css/CSS2/i18n/syndata/character-encoding-003.xht
! Crash => Skip css/CSS2/i18n/syndata/character-encoding-006.xht
! Crash => Skip css/CSS2/i18n/syndata/character-encoding-009.xht
! Crash => Skip css/CSS2/i18n/syndata/character-encoding-013.xht
! Crash => Skip css/CSS2/i18n/syndata/character-encoding-014.xht
! Crash => Skip css/CSS2/i18n/syndata/character-encoding-015.xht
! Crash => Skip css/CSS2/i18n/syndata/character-encoding-016.xht
! Crash => Skip css/css-syntax/charset/page-utf16-css-bomless-utf16.html
! Crash => Skip css/css-syntax/charset/page-utf16-css-bomless-utf16be.html
! Crash => Skip css/css-syntax/charset/page-utf16-css-no-decl-ascii-only.html
! Crash => Skip css/css-syntax/charset/page-utf16-css-no-decl.html
- Pass => Fail css/css-text-decor/text-emphasis-style-none-001.xht
- Pass => Fail css/css-text/text-transform/text-transform-none-001.xht

Generated by the WPT workflow.

@nicoburns nicoburns self-assigned this Aug 8, 2026
@staging-devin-ai-integration

Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

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