]> git.seodisparate.com - SimpleArchiver/commitdiff
WIP white/black-list: Fix b-contains behavior
authorStephen Seo <seo.disparate@gmail.com>
Mon, 17 Feb 2025 06:29:18 +0000 (15:29 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Mon, 17 Feb 2025 06:29:18 +0000 (15:29 +0900)
Up to this commit, --blacklist-contains would blacklist any entry that
matches any <text>.
This behavior has been changed to only blacklist any entry that contains
all <text> entries specified by multiple --blacklist-contains (or just 1
if there was only 1 flag).

TODO:
    - white/black-lists for test/extract for file format version 1 and
      2.
    - white/black-lists for create/test/extract for file format version
      0.

src/helpers.c

index 8150e2c0682b46afc3957771a148f099f6b75e85..7f5ac95abe502078258245494486b7e412bcb8e1 100644 (file)
@@ -765,16 +765,22 @@ uint_fast8_t simple_archiver_helper_string_allowed_lists(
   }
 
   if (b_contains) {
+    uint_fast8_t contains_all = 1;
     for (const SDArchiverLLNode *node = b_contains->head->next;
         node != b_contains->tail;
         node = node->next) {
       if (node->data) {
-        if (simple_archiver_helper_string_contains(
+        if (!simple_archiver_helper_string_contains(
             cstring, node->data, case_i)) {
-          return 0;
+          contains_all = 0;
+          break;
         }
       }
     }
+
+    if (contains_all) {
+      return 0;
+    }
   }
   if (b_begins) {
     for (const SDArchiverLLNode *node = b_begins->head->next;