Skip to content

Implement BOM stripping and ignoreBOM option in TextDecoder#4631

Merged
jedel1043 merged 2 commits intoboa-dev:mainfrom
apoorvdarshan:implement-textdecoder-bom-stripping
Feb 22, 2026
Merged

Implement BOM stripping and ignoreBOM option in TextDecoder#4631
jedel1043 merged 2 commits intoboa-dev:mainfrom
apoorvdarshan:implement-textdecoder-bom-stripping

Conversation

@apoorvdarshan
Copy link
Contributor

Summary

  • Strip BOM bytes by default during decoding (UTF-8, UTF-16LE, UTF-16BE) per the WHATWG Encoding spec
  • Support the ignoreBOM constructor option to opt out of stripping
  • Add read-only ignoreBOM getter property

Closes #4613

Test plan

  • Added tests for default BOM stripping (UTF-8, UTF-16LE, UTF-16BE)
  • Added tests for ignoreBOM: true preserving BOM for all three encodings
  • Added tests for ignoreBOM: false stripping BOM (same as default)
  • Added test for ignoreBOM getter returning correct values
  • All 50 boa_runtime tests pass with zero warnings

@github-actions
Copy link

github-actions bot commented Feb 17, 2026

Test262 conformance changes

Test result main count PR count difference
Total 52,862 52,862 0
Passed 49,472 49,471 -1
Ignored 2,249 2,249 0
Failed 1,141 1,142 +1
Panics 0 0 0
Conformance 93.59% 93.59% -0.00%
Broken tests (1):
test/intl402/NumberFormat/prototype/resolvedOptions/basic.js (previously Passed)

@nekevss nekevss requested a review from a team February 17, 2026 22:19
@nekevss nekevss added the A-Enhancement New feature or request label Feb 17, 2026
@codecov
Copy link

codecov bot commented Feb 17, 2026

Codecov Report

❌ Patch coverage is 90.78947% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.58%. Comparing base (6ddc2b4) to head (177202b).
⚠️ Report is 660 commits behind head on main.

Files with missing lines Patch % Lines
core/runtime/src/text/mod.rs 72.00% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4631      +/-   ##
==========================================
+ Coverage   47.24%   56.58%   +9.33%     
==========================================
  Files         476      548      +72     
  Lines       46892    60064   +13172     
==========================================
+ Hits        22154    33987   +11833     
- Misses      24738    26077    +1339     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@apoorvdarshan apoorvdarshan force-pushed the implement-textdecoder-bom-stripping branch from 402d234 to ac01cda Compare February 17, 2026 22:41
Copy link
Member

@jedel1043 jedel1043 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the contribution! It looks very good, I just have a suggestion to simplify the new tests.

@apoorvdarshan apoorvdarshan force-pushed the implement-textdecoder-bom-stripping branch from ac01cda to dad96e6 Compare February 20, 2026 18:45
@apoorvdarshan
Copy link
Contributor Author

Thanks for the review! Refactored the 9 individual BOM tests into 3 parameterized #[test_case] functions, following the roundtrip pattern. Also fixed the rustfmt issue from the earlier push.

@apoorvdarshan apoorvdarshan force-pushed the implement-textdecoder-bom-stripping branch from dad96e6 to 4d90a2f Compare February 20, 2026 19:06
…v#4613)

Strip BOM bytes by default during decoding (UTF-8, UTF-16LE, UTF-16BE)
per the WHATWG Encoding spec, and support the `ignoreBOM` constructor
option to opt out of stripping. Add `ignoreBOM` getter property.
Copy link
Member

@jedel1043 jedel1043 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@jedel1043 jedel1043 added the C-Builtins PRs and Issues related to builtins/intrinsics label Feb 22, 2026
@jedel1043 jedel1043 enabled auto-merge February 22, 2026 15:24
@jedel1043 jedel1043 added this pull request to the merge queue Feb 22, 2026
Merged via the queue into boa-dev:main with commit 3374052 Feb 22, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Enhancement New feature or request C-Builtins PRs and Issues related to builtins/intrinsics

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement BOM stripping and ignoreBOM option in TextDecoder

3 participants