8000 Empty UnparseableSections is not marked as rawBody · Issue #291 · go-ini/ini · GitHub
[go: up one dir, main page]

Skip to content

Empty UnparseableSections is not marked as rawBody #291

Closed

Description

@frankkopp

Describe the bug
When loading an ini with multiple sections with the last section as "UnparsableSection" and this last section is empty then the Section is not marked as rawBody and therefore can not be used to write raw data to.
It works well when at least one line of data is in the section.

To Reproduce
Loading:
tmpIni, err := ini.LoadSources(ini.LoadOptions{ UnparseableSections: []string{"customData"}, }, *c.IniFileName)

INI-file:
[customData]
image

Same code but with at least one line in the section:
image

Expected behavior
Every section marked with UnparseableSections should be a "rawBody" section. Even if it is empty

Screenshots
See above

Activity

  1. frankkopp commented on Jun 4, 2021

    @frankkopp
    Author

    Here is the piece in your code were it goes wrong:
    image

    The line 481: section.isRawSection = true is only executed after reading the the next line. If the file is at it's end it will never be set.

    Maybe move this line as per my suggestion in the screenshot?

  2. vzer200 commented on Sep 8, 2026

    @vzer200

    I’ll work on a focused fix in this session, with regression tests for empty unparseable sections at EOF and before a following section. The raw-section flag should be established when the section header is read, so SetBody works even when there is no body line.

  3. yuefdev commented on Oct 18, 2026

    @yuefdev

    I’m checking whether this still reproduces on current main and preparing a small regression for empty sections at EOF and before another section. I found no open or closed PR for #291; please flag any overlapping work.

  4. 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.

    In v2, UnparseableSections is renamed to the RawSections option.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0