Skip to content

Fix panic when decrypting INI files with empty comment lines - #2354

Open
eliasehmann wants to merge 1 commit into
getsops:mainfrom
eliasehmann:ini-empty-comment-lines
Open

eliasehmann wants to merge 1 commit into
getsops:mainfrom
eliasehmann:ini-empty-comment-lines

Conversation

@eliasehmann

Copy link
Copy Markdown

Fixes #766

An INI comment that starts with a line like ;;;;; can be encrypted, but decrypting the file panics. After the comment characters are stripped that line is empty, and the INI library cannot write an empty comment line.

Empty comment lines are now written as ;. This also makes files decryptable that were already encrypted with such a comment.

Note: an empty # line at the start of a comment comes back as ;.

Includes a test with the example from the issue.

A comment block that starts with a line of only comment characters,
like ';;;;;', ends up with an empty first line after stripCommentChar().
The INI library looks at the first character of every comment line when
writing and panics on an empty line, so such files could be encrypted,
but not decrypted again.

Empty comment lines are now written as ';'. This also makes files that
were already encrypted with such a comment decryptable.

Fixes getsops#766.

Signed-off-by: Elias Ehmann <41519164+eliasehmann@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

stores/ini - Block style comments fail to decrypt

1 participant