Skip to content

Fix precedence of overlapping file content filters - #243

Open
dajiaohuang wants to merge 1 commit into
CyberShadow:masterfrom
dajiaohuang:fix/content-filter-order-20261015
Open

dajiaohuang wants to merge 1 commit into
CyberShadow:masterfrom
dajiaohuang:fix/content-filter-order-20261015

Conversation

@dajiaohuang

Copy link
Copy Markdown

Problem

The README and AddFileContentFilter helper document that the most recently registered matching pattern takes precedence. AconfCompileSystem instead iterates the keys of an associative array, so overlapping filters are selected in hash order rather than configuration order.

For example, registering a timestamp-removal filter for /etc/second/connection followed by an identity filter for /etc/second/* should preserve the timestamp for that file. On the current base, the earlier filter wins instead, and aconfmgr save emits an unexpected CopyFile overriding the configured contents. Re-registering a pattern after another matching pattern also does not reliably give it precedence.

Change

Record pattern registrations in an indexed array and use that order when selecting the last matching filter. Keep the existing pattern-to-function mapping. Add a save-path regression covering broad/specific patterns in both orders and re-registration of an existing pattern.

Validation

  • New regression fails on 96ab414343b9467fca5ef46f04bc1bd1fc7bd8f1, emitting two unexpected CopyFile lines; passes with the fix.
  • All 93 mock test scripts pass in a disposable Linux container (92 existing plus the regression).
  • make lint passes, including the pinned ShellCheck 0.11.0 and style checks.
  • CLI help, configuration compilation/check (including file copying, generated content and symlinks), and cached-state diff pass with synthetic files.
  • Arch/AUR integration mode was not run; package-manager behavior was exercised only through the project's mocks. No real host configuration was read or applied.

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.

1 participant