X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fsieve.c;h=cce70574ae927c451f165af0488e47215e27ac8c;hb=HEAD;hp=a49d6b30d29a2fe063b33ea4ffb9a83890317dec;hpb=3841dfefb6b086720b6d5d9af39aaf8b19730e6d;p=citadel.git diff --git a/webcit/sieve.c b/webcit/sieve.c index a49d6b30d..2e3d61585 100644 --- a/webcit/sieve.c +++ b/webcit/sieve.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996-2012 by the citadel.org team + * Copyright (c) 1996-2020 by the citadel.org team * * This program is open source software. You can redistribute it and/or * modify it under the terms of the GNU General Public License version 3. @@ -9,230 +9,23 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * FIXME: add logic to exclude the webcit-generated script from the manual script selection + * + * Implementation note: this was kind of hacked up when we switched from Sieve to custom rules. + * As a result there's probably some cruft in here... + * ajc 2020jul12 + * */ #include "webcit.h" +CtxType CTX_SIEVELIST = CTX_NONE; +CtxType CTX_SIEVESCRIPT = CTX_NONE; + #define MAX_SCRIPTS 100 #define MAX_RULES 50 #define RULES_SCRIPT "__WebCit_Generated_Script__" -/* - * Helper function for output_sieve_rule() to output strings with quotes escaped - */ -void osr_sanitize(char *str) { - int i, len; - - if (str == NULL) return; - len = strlen(str); - for (i=0; i 0) { - for (i=0; i sizeof(WC_RULE_HEADER) - 1) && - (!strncasecmp(ChrPtr(Line), HKEY(WC_RULE_HEADER)))) + if ((StrLength(Line) > sizeof(WC_RULE_HEADER) - 1) && (!strncasecmp(ChrPtr(Line), HKEY(WC_RULE_HEADER)))) { StrBufSkip_NTokenS(Line, &pch, '|', 1); n = StrBufExtractNext_int(Line, &pch, '|'); @@ -890,6 +574,8 @@ void InitModule_SIEVE (void) { + RegisterCTX(CTX_SIEVELIST); + RegisterCTX(CTX_SIEVESCRIPT); REGISTERTokenParamDefine(from); REGISTERTokenParamDefine(tocc); REGISTERTokenParamDefine(subject); @@ -929,21 +615,21 @@ InitModule_SIEVE RegisterIterator("SIEVE:SCRIPTS", 0, NULL, GetSieveScriptListing, NULL, NULL, CTX_SIEVELIST, CTX_NONE, IT_NOFLAG); - RegisterConditional(HKEY("COND:SIEVE:SCRIPT:ACTIVE"), 0, ConditionalSieveScriptIsActive, CTX_SIEVELIST); - RegisterConditional(HKEY("COND:SIEVE:SCRIPT:ISRULES"), 0, ConditionalSieveScriptIsRulesScript, CTX_SIEVELIST); + RegisterConditional("COND:SIEVE:SCRIPT:ACTIVE", 0, ConditionalSieveScriptIsActive, CTX_SIEVELIST); + RegisterConditional("COND:SIEVE:SCRIPT:ISRULES", 0, ConditionalSieveScriptIsRulesScript, CTX_SIEVELIST); RegisterNamespace("SIEVE:SCRIPT:NAME", 0, 1, tmplput_SieveScriptName, NULL, CTX_SIEVELIST); RegisterNamespace("SIEVE:SCRIPT:CONTENT", 0, 1, tmplput_SieveScriptContent, NULL, CTX_SIEVELIST); RegisterIterator("SIEVE:RULES", 0, NULL, GetSieveRules, NULL, DeleteHash, CTX_SIEVESCRIPT, CTX_NONE, IT_NOFLAG); - RegisterConditional(HKEY("COND:SIEVE:ACTIVE"), 1, ConditionalSieveRule_Active, CTX_SIEVESCRIPT); - RegisterConditional(HKEY("COND:SIEVE:HFIELD"), 1, ConditionalSieveRule_hfield, CTX_SIEVESCRIPT); - RegisterConditional(HKEY("COND:SIEVE:COMPARE"), 1, ConditionalSieveRule_compare, CTX_SIEVESCRIPT); - RegisterConditional(HKEY("COND:SIEVE:ACTION"), 1, ConditionalSieveRule_action, CTX_SIEVESCRIPT); - RegisterConditional(HKEY("COND:SIEVE:SIZECOMP"), 1, ConditionalSieveRule_sizecomp, CTX_SIEVESCRIPT); - RegisterConditional(HKEY("COND:SIEVE:FINAL"), 1, ConditionalSieveRule_final, CTX_SIEVESCRIPT); - RegisterConditional(HKEY("COND:SIEVE:THISROOM"), 1, ConditionalSieveRule_ThisRoom, CTX_SIEVESCRIPT); + RegisterConditional("COND:SIEVE:ACTIVE", 1, ConditionalSieveRule_Active, CTX_SIEVESCRIPT); + RegisterConditional("COND:SIEVE:HFIELD", 1, ConditionalSieveRule_hfield, CTX_SIEVESCRIPT); + RegisterConditional("COND:SIEVE:COMPARE", 1, ConditionalSieveRule_compare, CTX_SIEVESCRIPT); + RegisterConditional("COND:SIEVE:ACTION", 1, ConditionalSieveRule_action, CTX_SIEVESCRIPT); + RegisterConditional("COND:SIEVE:SIZECOMP", 1, ConditionalSieveRule_sizecomp, CTX_SIEVESCRIPT); + RegisterConditional("COND:SIEVE:FINAL", 1, ConditionalSieveRule_final, CTX_SIEVESCRIPT); + RegisterConditional("COND:SIEVE:THISROOM", 1, ConditionalSieveRule_ThisRoom, CTX_SIEVESCRIPT); RegisterNamespace("SIEVE:SCRIPT:HTEXT", 0, 1, tmplput_SieveRule_htext, NULL, CTX_SIEVESCRIPT); RegisterNamespace("SIEVE:SCRIPT:SIZE", 0, 1, tmplput_SieveRule_sizeval, NULL, CTX_SIEVESCRIPT); @@ -954,7 +640,5 @@ InitModule_SIEVE /* fetch our room into WCC->ThisRoom, to evaluate while iterating over rooms with COND:THIS:THAT:ROOM */ RegisterNamespace("SIEVE:SCRIPT:LOOKUP_FILEINTO", 0, 1, tmplput_SieveRule_lookup_FileIntoRoom, NULL, CTX_SIEVESCRIPT); WebcitAddUrlHandler(HKEY("save_sieve"), "", 0, save_sieve, 0); - WebcitAddUrlHandler(HKEY("create_script"), "", 0, create_script, 0); - WebcitAddUrlHandler(HKEY("delete_script"), "", 0, delete_script, 0); WebcitAddUrlHandler(HKEY("display_sieve_add_or_delete"), "", 0, display_sieve_add_or_delete, 0); }