question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CSS files with UTF-8 BOM triggers CSS errors

See original GitHub issue

I noticed that if a CSS file has a UTF-8 BOM then HtmlUnit seems to not like it - It throws a CSS error:

com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: 'http://localhost:59425/cargo-daemon-webapp/cargo.css' [38:1] Error in style rule. (Invalid token "body". Was expecting one of: <S>, <LBRACE>, <COMMA>.)

The UTF-8 BOM doesn’t seem to “bother” Web browsers, could HtmlUnit also be updated to behave similarly?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
rbricommented, Jul 17, 2020

Ok, hopefully i have covered the most important cases. Please check twitter for a new snapshot build.

Many thanks for reporting this.

1reaction
rbricommented, Jul 14, 2020

I think it could be worthwhile to enable HtmlUnit to work with UTF-8 BOMed files, as Windows tends to save with a BOM and browsers seem to be fine with it.

Yes this is the plan - removing the BOM is not so tricky (i already did it at some other places) but it will require some time to think about test cases to ensure the same behavior as real browsers.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fix "Byte-Order Mark found in UTF-8 File" validation ...
Open the file with Geany. In the menu "Dokument" uncheck "Write Unicode BOM". Save the file. Save this answer.
Read more >
Display problems caused by the UTF-8 BOM - W3C
Answer. If you are dealing with a file encoded in UTF-8, your display problems may be caused by the presence of a UTF-8...
Read more >
CSS files encoded in UTF-8 with BOM break the design when ...
Problem/Motivation. If a css file is encoded in UTF-8 with BOM (byte order mark) it breaks the design when enabling css aggregation.
Read more >
Ensure all script, css and html files are UTF-8 with BOM #266
So I propose to do a PR with the scripts conforming to UTF-8 encoding with BOM, so that this can be tested on...
Read more >
Checking for boms in files - Get Started - SitePoint Forums
I just want to be sure. Right now, my PHP, HTML, JS, and CSS files are all saved in the UTF-8 Without BOM...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found