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

Parser: Allow literal control chars in logfmt decoder #3932

Merged
merged 2 commits into from
Jul 19, 2021

Conversation

Timbus
Copy link
Contributor

@Timbus Timbus commented Jul 2, 2021

What this PR does / why we need it:
This allows logfmt to handle newlines so long as they are quoted as expected. It still unquotes control chars so nothing should ever break. It just throws less errors.

Rant
There are other issues I have ignored. The main one being that the ScanKeyval parser tries to be more efficient by avoiding calling unquoteBytes unless it sees a \, but it relies on unquoteBytes to handle utf8. So a unicode token without a \ may not be decoded correctly.
unquoteBytes also has its own logic to check for slashes so it's inefficient
unquoteBytes also seems to expect that the given string starts and ends with " but surely anything passing the string has already checked for these delimiters so, why pass them?.. another mystery. And also why does it care if it finds an unescaped quote char, if its not a stream scanner?
Basically someone should inline some of unquoteBytes code into ScanKeyval, is what I'm getting at.

Which issue(s) this PR fixes:
Fixes #3927

Checklist

  • Documentation added
  • Tests updated

@CLAassistant
Copy link

CLAassistant commented Jul 2, 2021

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@cyriltovena cyriltovena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cyriltovena cyriltovena merged commit 267107b into grafana:main Jul 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] Newlines in logfmt sometimes work, sometimes don't
3 participants