yq icon indicating copy to clipboard operation
yq copied to clipboard

control characters are not allowed

Open dene14 opened this issue 3 years ago • 2 comments

Describe the bug Error: yaml: control characters are not allowed e.g. \x01 \x02

Version of yq: 4.9.3 Operating system: linux Installed via: binary release

Seems related: https://stackoverflow.com/questions/33717799/go-yaml-control-characters-are-not-allowed-error

dene14 avatar Jun 07 '21 11:06 dene14

This could also be related to: https://github.com/mikefarah/yq/issues/814 - which is also a go-yaml issue. Have you tried raising an issue there?

mikefarah avatar Jun 08 '21 11:06 mikefarah

$ # MWE
$ hx --health yaml | sed -n '5p;'
Highlight queries: ✓

$ # Bug Reproduction
$ hx --health yaml | sed -n '5p;' | yq
Error: bad file '-': yaml: control characters are not allowed

$ # Diagnosing
$ hx --health yaml | sed -n '5p;' | od -c
0000000   H   i   g   h   l   i   g   h   t       q   u   e   r   i   e
0000020   s   :     033   [   3   8   ;   5   ;   1   0   m 342 234 223
0000040 033   [   3   9   m  \n
0000046

$ # Treatment: Removing control chars (color sequqnce)
$ hx --health yaml | sed -n '5p;' | sd '\x1b\[[0-9;m]+' ''
Highlight queries: ✓

$ # Verification (subtle)
$ hx --health yaml | sed -n '5p;' | sd '\x1b\[[0-9;m]+' '' | yq
Highlight queries: ✓

$ # Verification (explicit)
$ hx --health yaml | sed -n '5p;' | sd '\x1b\[[0-9;m]+' '' | yq 'keys,.[]'
- Highlight queries
✓

versions

$ yq -V
yq (https://github.com/mikefarah/yq/) version v4.42.1

$ systeminfo | grep -iA1 "os name"
OS Name:                   Microsoft Windows 10 Home Single Language
OS Version:                10.0.19045 N/A Build 19045

goyalyashpal avatar Mar 24 '24 20:03 goyalyashpal