Repository navigation
grep: handle malformed color environment values - #139
Conversation
Ignore malformed `GREP_COLOR` values without warning. Stop parsing `GREP_COLORS` at a malformed entry or empty key while keeping entries parsed before it. Do not discard the whole variable when it contains invalid UTF-8.
Merging this PR will not alter performance
|
| // Decode lossily to preserve valid entries; replacement characters cannot | ||
| // match capability names or pass color-value validation. |
There was a problem hiding this comment.
What's the point of trying to recover a malformed non-UTF8 GREP_COLORS env variable?
There was a problem hiding this comment.
Not much, GNU does keep valid entries around a bad byte, but this isn't a realistic environment value and isn't worth the extra handling. I dropped that part so a non-UTF-8 GREP_COLORS is ignored as a whole again.
Keep the existing behavior for non-UTF-8 values and treat the whole variable as unset. Recovering valid entries around a bad byte is not worth the extra handling here.
Ignore a malformed
GREP_COLORwithout printing the deprecation warning. Valid values still work and still produce the warning.When parsing
GREP_COLORS, stop at the first malformed entry or empty key, but keep entries parsed before it.GNU prints the match in its default color without a warning. uutils previously printed a warning and used
^[[4x2mas the escape sequence.Fixes #135