hiera-eyaml icon indicating copy to clipboard operation
hiera-eyaml copied to clipboard

Trailing newline is added during encryption/decryption

Open danielparks opened this issue 6 years ago • 4 comments

Hiera eyaml 2.1.0 ensures there is a trailing newline when run from the command line.

❯ echo -n nonl >no_newline
❯ od -c no_newline
0000000    n   o   n   l
0000004
❯ eyaml encrypt -f no_newline -o string | tr -d '\n' | eyaml decrypt --stdin | od -c 
0000000    n   o   n   l  \n                                            
0000005
❯ echo yesnl >yes_newline 
❯ od -c yes_newline 
0000000    y   e   s   n   l  \n                                        
0000006
❯ eyaml encrypt -f yes_newline -o string | tr -d '\n' | eyaml decrypt --stdin | od -c
0000000    y   e   s   n   l  \n                                        
0000006

This is inconsistent. It should either add the newline (nonl\n and yesnl\n\n) or not add the newline (nonl and yesnl\n).

Originally #264, though I got the title backward that time. Thanks to @bifek for finding a good test case.

danielparks avatar Dec 07 '18 08:12 danielparks

encryption is fine. even decryption itself is fine, it's only in emitting the output that it unnecessary adds newline. see #270

bifek avatar Dec 07 '18 08:12 bifek

A simpler example:

❯ eyaml encrypt -s nonl -o string | tr -d '\n' | eyaml decrypt --stdin | od -c
0000000    n   o   n   l  \n                                            
0000005

danielparks avatar Dec 09 '18 03:12 danielparks

Hi folks,

I'd like to add that this issue seems to only manifest in eyaml output mode string. If I use the block output (and the according syntax in hiera itself) the output is what you would expect.

Might help to narrow down the issue.

EDIT: well this somehow is obvious from the examples above because -o string is used, but I thought I'd spell it out.

Cheers Thomas

TwizzyDizzy avatar Feb 17 '21 21:02 TwizzyDizzy

in my testing this is the same

% { echo '>'; echo -n nonl | eyaml encrypt --stdin -o block; } | eyaml decrypt --stdin | od -c
0000000   n   o   n   l  \n

bifek avatar Feb 18 '21 12:02 bifek