-
Notifications
You must be signed in to change notification settings - Fork 79
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
Parse/Encode logfmt is not idempotent when values have double quotes #777
Comments
Thanks for raising this, I think you're absolutely right about the principle. I would like to take a stab at fixing this. |
I got a test reproducing the error this evening. The problem is the same in both directions: decoding does not remove escape characters. I've been testing the encode/decode value functions, so I don't think it's just the logfmt functions. |
Adding some parsing escape removal to parsing sounds like the right fix to me. It would be a breaking change for people who are relying on escape characters being preserved when parsing. |
As far as I can tell this is fixed for the case of In fact the output is the same regardless of whether the string contains |
vrl/src/core/encode_key_value.rs Line 116 in f258a70
Think maybe this should be changed to r"\n" ?
|
I think an issue here might be that |
I think this is exactly it, silly mistake on my part! I've added a newline character to the encode_decode / decode_encode cycle tests and they fail:
the decode_encode_cycle test fails a bit more spectacularly!
Making hte change: '\n' => output.push_str(r"\n"), fixes the encode_decode cycle, but doesn't quite fix the decode_encode_cycle: The new failure with the change is:
I am not sure how to fix this to make a full encode -> decode -> encode cycle work.
Perhaps this is causing the remaining test failure? |
In general, any encode/decode function pairs should be idempotent; that is, this should always be true:
It appears to not be the case with
encode_logfmt
andparse_logfmt
, as demonstrated here, whereresult.key
has additional escape characters.Taken to the extreme:
yields:
This isn't really causing me any headaches, and the fact that it hasn't been raised yet probably indicates the same for other folks, just thought it was worth bringing up, as I stumbled on it today.
The text was updated successfully, but these errors were encountered: