Skip to content

Broken dotenv output for values with spaces #1951

@mszczepanczyk

Description

@mszczepanczyk

Strings containing spaces are not quoted nor escaped in output dotenv files. The only way I've found to produce proper dotenv files in such case is manually quoting each space in the source yaml as quoting isn't possible (related issue #949).

To reproduce

# BAD
$ echo -e "FOO: Some long string with spaces" | sops encrypt --filename-override .yaml | sops decrypt --filename-override .yaml --output-type dotenv
FOO=Some long string with spaces

# BAD
$ echo -e "FOO: 'Some long string with spaces'" | sops encrypt --filename-override .yaml | sops decrypt --filename-override .yaml --output-type dotenv
FOO=Some long string with spaces

# GOOD
$ echo -e "FOO: Some\ long\ string\ with\ spaces" | sops encrypt --filename-override .yaml | sops decrypt --filename-override .yaml --output-type dotenv
FOO=Some\ long\ string\ with\ spaces

Expected behavior

$ echo -e "FOO: Some long string with spaces" | sops encrypt --filename-override .yaml | sops decrypt --filename-override .yaml --output-type dotenv
FOO="Some long string with spaces"

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/storesnot-a-bugSOPS behaves as designed, though apparently not as the user expectedstores/dotenv

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions