Repository navigation
fix(filter): keep the whole regex when it contains a colon - #3674
Merged
nicolargo merged 1 commit intoAug 26, 2026
Merged
Conversation
`GlancesFilter.filter` split the input on every colon and kept only the second
field, so everything after the second colon was discarded:
cmdline:C:/Program Files/.* -> key=cmdline regex=C
name:foo:bar -> key=name regex=foo
The truncation is silent. The leading fragment is usually still a valid regex —
`C` compiles — so the compile guard never fires, the filter matches nothing, and
the process list comes back empty with no error and only a debug log line.
On Windows that is every absolute path, since each one has a drive colon. It
also truncates URLs, IPv6 literals and any `foo:bar` process name.
`split(':', 1)` rather than the repo's `split_esc`: that helper escapes on
backslash and strips the escape characters from its result, which would mangle a
Windows path regex. The separator here needs no escaping — the key never
contains a colon.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The defect
GlancesFilter.filtersplits the input on every colon and keeps only the second field (glances/filter.py:113):So everything after the second colon is discarded. Measured on
develop:cmdline:C:/Program Files/.*cmdlineCname:foo:barnamefooAnd the truncated filter then rejects the process it was written for:
The truncation is silent. The leading fragment is usually still a valid regex —
Ccompiles fine — so theexceptaroundre.compileat:134never fires. The user gets an empty process list, no error, and onedebug-level log line.On Windows this is every absolute path, because each one carries a drive colon. It is not Windows-only, though: it also truncates URLs, IPv6 literals, and any
foo:barprocess name.The fix
value.split(':', 1).I looked at the repo's own
split_esc(glances/globals.py:677) first, sinceplugins/plugin/model.py:1069already uses it for akey:valuepair. It is the wrong tool here: it escapes on backslash and removes the escape characters from its result, which would mangle a Windows path regex likeC:\Windows\.*. The separator in this field needs no escaping — a filter key never contains a colon — so plainmaxsplitis both smaller and correct. There is a test pinning that backslashes survive.Verification
Windows 11, Python 3.14.7.
Mutation-checked, after confirming the edit applied: restoring
split(':')failstest_020_filterwithAssertionError: 'C' != 'C:/Program Files/.*'.Tests
Extends the existing
test_020_filter, which already exercisesGlancesFilterthis way, with three cases: a path regex carrying a drive colon, the same shape without a path (name:foo:bar, so the case is not read as Windows-only), and a backslash-bearing regex asserting the escapes survive the split.One thing I did not change: a filter written as a bare regex with a colon in it, such as
http://.*, still has its scheme read as the key. This fix stops the regex being truncated but does not disambiguate that; validating the key against the known process fields would, and that is a larger decision than this one-token change.