GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Do not emit multiple UTF-8 BOM markers by arronKler · Pull Request #2136 · postcss/postcss

Conversation

@arronKler

@arronKler arronKler commented Aug 14, 2026

Copy link
Copy Markdown

Why

v8.5.24 started restoring a leading BOM on stringify (#2119). That is correct for a single file, but parse/stringify could still produce more than one U+FEFF:

  • input with several leading BOMs kept extras after the first
  • concatenated CSS (a{}\uFEFFb{}) re-emitted the mid-file marker as part of the next selector
  • a Document of several BOM-tagged roots wrote a BOM before every root

Those extra markers show up in the middle of generated CSS and break the first rule after each one.

Solution

  • Strip every leading U+FEFF / U+FFFE in Input, not only the first
  • Skip stray BOM markers in the tokenizer so they are not part of the AST
  • Emit at most one BOM from Stringifier#root

A single leading BOM is still preserved. parse('\uFEFFa{}').toString() remains \uFEFFa{}.

Fixes #2133

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@arronKler
Do not emit multiple UTF-8 BOM markers
d3ecc2c
8.5.24 restored a leading BOM on stringify. Concatenated CSS and
documents with several BOM-tagged roots then contained U+FEFF in the
middle of the output.

Strip every leading BOM on parse, skip stray markers while tokenizing,
and emit at most one BOM when stringifying.

Fixes postcss#2133
ai
ai reviewed Aug 14, 2026
View reviewed changes
Comment thread lib/tokenize.js

function nextToken(opts) {
if (returned.length) return returned.pop()
skipBom()

@ai ai Aug 14, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Why do we need it if we already have this.css.replace(/^[\uFEFF\uFFFE]+/, '')?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
This was referenced Aug 14, 2026
Fix rule end offset when spaces precede its own semicolon #2135
Merged
Multiple BOM symbols inside generated css in v8.5.24 #2133
Open
@ai

ai commented Aug 16, 2026

Copy link
Copy Markdown
Member

@romainmenke found an issue with current approach

This removal isn't correct as U+FEFF is only a BOM if found at the start and has another (deprecated) meaning if found elsewhere, as a zero width no-break space.

But we still can think of removing U+FEFF in the context where U+FEFF is illegal anyway

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@hannaseithe hannaseithe mentioned this pull request Aug 25, 2026
Pin version for postcss (Fix for wrongly rendered icons) digitalfabrik/integreat-cms#4535
Merged
@MaciejZet

MaciejZet commented Oct 17, 2026

Copy link
Copy Markdown

I tested d3ecc2c against its base and current main (f1aca7e) locally on macOS.

Chrome 155 confirms the earlier U+FEFF concern: parse('a { grid-area: \uFEFF; }').toString() loses the literal character, leaving an empty value and computed grid-area: auto. Base and main preserve it. The CSS escape \FEFF is preserved by all three.

One remaining Document case: a first root from parse('a{}'), followed by parse('\uFEFFb{}'), still produces a{}\uFEFFb{} with this PR. This gap also exists on the base; current main produces a{}b{}.

The failed Node 14 job resolved [email protected], versus 8.9.0 in the lockfile. Switching only those fixtures on Node 14/TypeScript 4.9.5 reproduces the same semicolons.css failure on both base and PR; main passes. That failure is therefore separate from the BOM change.

With locked dependencies, the PR passes all 691 unit tests on Node 10/12/14/16/18/20/22/24/26 and the full pnpm test on Node 26. I haven't reproduced the reporter's webpack/Sass build.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This branch has not been deployed

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

Reviewers

@ai ai ai left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Multiple BOM symbols inside generated css in v8.5.24

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@arronKler @ai @MaciejZet
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.