Skip to content

VRL REPL doesn't parse "\u" neither "\x" escapes #1275

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

Closed
ulidtko opened this issue Feb 17, 2025 · 3 comments
Closed

VRL REPL doesn't parse "\u" neither "\x" escapes #1275

ulidtko opened this issue Feb 17, 2025 · 3 comments
Labels
type: bug A code related bug

Comments

@ulidtko
Copy link

ulidtko commented Feb 17, 2025

Hi! Per my reading of https://vector.dev/docs/reference/vrl/expressions/#string this should work:

$ "\u001b[95m Hello, string literals?"

error[E202]: syntax error
  ┌─ :1:1
  │
1 │ "\u001b[95m Hello, string literals?"
  │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unexpected error: invalid escape character: \u
  │
  = see language documentation at https://vrl.dev
  = try your code in the VRL REPL, learn more at https://vrl.dev/examples

as well as "-string literal with \x escape:

$ "\x33"

error[E202]: syntax error
  ┌─ :1:1
  │
1 │ "\x33"
  │ ^^^^^^ unexpected error: invalid escape character: \x
  │
  = see language documentation at https://vrl.dev
  = try your code in the VRL REPL, learn more at https://vrl.dev/examples

Yet, both give syntax error in the REPL.

Version

vector 0.44.0 (x86_64-unknown-linux-gnu 3cdc7c3 2025-01-13 21:26:04.735691656)

@ulidtko ulidtko added the type: bug A code related bug label Feb 17, 2025
@ulidtko
Copy link
Author

ulidtko commented Feb 18, 2025

Somehow, the escapes do work in regex literals 🤷

So, with vector vrl --input, I managed to verify in REPL that this indeed strips ANSI colors escape sequences, as expected:

.message = string!(.message)
.message = replace(.message, r'\x1b\[[0-9;]*m', "")

@pront pront transferred this issue from vectordotdev/vector Feb 18, 2025
@u1735067
Copy link

u1735067 commented Feb 18, 2025

Probably a duplicate of #148?

However since I don't saw anyone mentioning it (outside of issue 6863 in vector), as a workaround decode_base16!("1b") can be used:

esc = decode_base16!("1b")
"{{esc}}[95mHello, string literals?{{esc}}[0m"

@pront
Copy link
Member

pront commented Feb 18, 2025

Duplicate per #1275 (comment)

@pront pront closed this as completed Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A code related bug
Projects
None yet
Development

No branches or pull requests

3 participants