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

Backslashes should probably be escaped #15

Open
Feuermurmel opened this issue May 30, 2024 · 3 comments
Open

Backslashes should probably be escaped #15

Feuermurmel opened this issue May 30, 2024 · 3 comments

Comments

@Feuermurmel
Copy link

I tested Grafana's logfmt parser. It doesn't accept e.g foo="\". It simply discards the pair. Tested with a query like this:

{...} | line_format "foo=\"\\\"" | logfmt

But this works:

{...} | line_format "foo=\"\\\\\"" | logfmt

Producing a field containing a single backslash.

@jteppinette
Copy link
Owner

@Feuermurmel Thank you for this report.

foo=\"\\\\\"

Gotta love that haha

What are your thoughts here. This should be fixed in python-logfmter, I assume?

@jteppinette
Copy link
Owner

@Feuermurmel Do you know if Grafana uses an open source package for its logfmt parsing?

@Feuermurmel
Copy link
Author

Feuermurmel commented Jun 9, 2024

What are your thoughts here. This should be fixed in python-logfmter, I assume?

I'd say so. Also because, for example, these two values produce the same output now:

import logfmter

print(logfmter.Logfmter().format_params(dict(foo="\\\"")))
print(logfmter.Logfmter().format_params(dict(foo='\\"')))
foo=\\"
foo=\\"

@Feuermurmel Do you know if Grafana uses an open source package for its logfmt parsing?

I'm not good at reading Go, but if I read the implementation of Process() here correctly, it uses go-logfmt/logfmt to parse Logfmt, specifically the implementation in ScanKeyval().

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

No branches or pull requests

2 participants