Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

control characters are not allowed #845

Open
dene14 opened this issue Jun 7, 2021 · 3 comments
Open

control characters are not allowed #845

dene14 opened this issue Jun 7, 2021 · 3 comments
Labels

Comments

@dene14
Copy link

dene14 commented Jun 7, 2021

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

@mikefarah
Copy link
Owner

This could also be related to: #814 - which is also a go-yaml issue. Have you tried raising an issue there?

@goyalyashpal
Copy link

goyalyashpal commented Mar 24, 2024

$ # 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

@gisostallenberg
Copy link

For me this was solved using --no-colors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants