]> git.seodisparate.com - SimpleArchiver/commitdiff
Fix whitelist begins-with/ends-with
authorStephen Seo <seo.disparate@gmail.com>
Tue, 25 Feb 2025 01:55:07 +0000 (10:55 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Tue, 25 Feb 2025 01:55:07 +0000 (10:55 +0900)
src/helpers.c

index 46fdc86af08431a855e6a18fed6c61936a851599..9ec87c24b64fb6362b29595cb1e6111cdfb4d2a4 100644 (file)
@@ -759,27 +759,37 @@ uint_fast8_t simple_archiver_helper_string_allowed_lists(
     }
   }
   if (parsed->whitelist_begins) {
+    uint_fast8_t contains = 0;
     for (const SDArchiverLLNode *node = parsed->whitelist_begins->head->next;
         node != parsed->whitelist_begins->tail;
         node = node->next) {
       if (node->data) {
-        if (!simple_archiver_helper_string_starts(
+        if (simple_archiver_helper_string_starts(
             cstring, node->data, case_i)) {
-          return 0;
+          contains = 1;
+          break;
         }
       }
     }
+    if (!contains) {
+      return 0;
+    }
   }
   if (parsed->whitelist_ends) {
+    uint_fast8_t contains = 0;
     for (const SDArchiverLLNode *node = parsed->whitelist_ends->head->next;
         node != parsed->whitelist_ends->tail;
         node = node->next) {
       if (node->data) {
-        if (!simple_archiver_helper_string_ends(cstring, node->data, case_i)) {
-          return 0;
+        if (simple_archiver_helper_string_ends(cstring, node->data, case_i)) {
+          contains = 1;
+          break;
         }
       }
     }
+    if (!contains) {
+      return 0;
+    }
   }
 
   if (parsed->blacklist_contains_any) {