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

ruleguard: fix interpolation of vars with common prefix #123

Merged
merged 1 commit into from
Nov 7, 2020

Conversation

quasilyte
Copy link
Owner

If pattern had variables where one of them is a prefix of another,
there was a chance of incorrect results.

This change makes renderMessage() sort keys and interpolate longer
var names first, so we avoid that risk.

Scratch slice is used to do the sorting, so no extra allocations
is added. As successfull matching is far less frequent than
a failed (or rejected) match, sorting should not affect the performance.

Signed-off-by: Iskander Sharipov quasilyte@gmail.com

If pattern had variables where one of them is a prefix of another,
there was a chance of incorrect results.

This change makes renderMessage() sort keys and interpolate longer
var names first, so we avoid that risk.

Scratch slice is used to do the sorting, so no extra allocations
is added. As successfull matching is far less frequent than
a failed (or rejected) match, sorting should not affect the performance.

Signed-off-by: Iskander Sharipov <quasilyte@gmail.com>
@quasilyte quasilyte merged commit f51a753 into master Nov 7, 2020
@quasilyte quasilyte deleted the quasilyte/fix/rendermessage_common_prefix branch November 7, 2020 17:03
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

Successfully merging this pull request may close these issues.

2 participants