8000 ini-files with two BOMs confuse the parser · Issue #390 · go-ini/ini · GitHub
[go: up one dir, main page]

Skip to content

ini-files with two BOMs confuse the parser #390

Closed

Description

@klaernie

Version

v1.67.3-2-g3b7d6ad (current main branch + the reproduction test case I linked below as well)

Describe the bug

When parsing a file that contains two byte-order-marks at the start of the file, which are not followed by a valid non-comment statement, causes the parser to trip with an error like this:

key-value delimiter not found: # this line is not parsed successfully

To reproduce

I prepared a test case, based on the UTF-8-BOM.ini testcase, that cleanly reproduces the issue, so you can simply checkout my fork and run the test case.

Expected behavior

These files are out in the wild and IMHO the parser should at least be clever enough to recognize them and warn the user that their file is technically broken. One could argue that it's not the responsibility of go-ini, but I would hope that it could be tolerant enough to return the valid data it can parse, and possibly fix the error when editing a file directly.

Additional context

This has originally been reported as an issue for editorconfig-checker, which uses the editorconfig-core library, which in turn uses go-ini to parse the .editorconfig files:

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

  1. unknwon commented on Nov 11, 2026

    @unknwon
    Member

    Fixed in v2 by #435, and will be in the next v2 pre-release after v2.0.0-beta.2. v2 is imported as unknwon.dev/ini/v2; see the migration guide for upgrading from v1.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0