From: Art Cancro Date: Thu, 16 Nov 2006 04:32:22 +0000 (+0000) Subject: Rules editor now encodes the form fields and saves them X-Git-Tag: v7.86~3843 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=bd5cad8b9b88376f40a564696061b9ffe845c5b9 Rules editor now encodes the form fields and saves them into a hidden script. Still need to write the decoding side, and the script generator. --- diff --git a/webcit/messages.c b/webcit/messages.c index 15446c75f..67d2b5054 100644 --- a/webcit/messages.c +++ b/webcit/messages.c @@ -2607,7 +2607,7 @@ void post_mime_to_server(void) { encoded_length = ((att->length * 150) / 100); encoded = malloc(encoded_length); if (encoded == NULL) break; - CtdlEncodeBase64(encoded, att->data, att->length); + CtdlEncodeBase64(encoded, att->data, att->length, 1); serv_printf("--%s", boundary); serv_printf("Content-type: %s", att->content_type); diff --git a/webcit/sieve.c b/webcit/sieve.c index da7c85d37..4cf8afdb3 100644 --- a/webcit/sieve.c +++ b/webcit/sieve.c @@ -10,6 +10,7 @@ #define MAX_SCRIPTS 100 #define MAX_RULES 25 +#define RULES_SCRIPT "__WebCit_Generated_Script__" /** * \brief view/edit sieve config @@ -21,6 +22,7 @@ void display_sieve(void) int active_script = (-1); char buf[256]; int i; + int rules_script_is_active = 0; memset(script_names, 0, sizeof script_names); @@ -32,6 +34,9 @@ void display_sieve(void) extract_token(script_names[num_scripts], buf, 0, '|', 64); if (extract_int(buf, 1) > 0) { active_script = num_scripts; + if (!strcasecmp(script_names[num_scripts], RULES_SCRIPT)) { + rules_script_is_active = 1; + } } ++num_scripts; } @@ -90,11 +95,12 @@ void display_sieve(void) wprintf(_("Leave it in my inbox without filtering")); wprintf("\n"); - wprintf("\n"); - wprintf("\n"); @@ -124,11 +130,13 @@ void display_sieve(void) wprintf(_("The currently active script is: ")); wprintf("\n"); } @@ -140,16 +148,18 @@ void display_sieve(void) if (num_scripts > 0) { for (i=0; i\n", script_names[i]); - wprintf("\n"); + wprintf("\n"); } - wprintf("\n"); - wprintf("\n"); } } @@ -200,10 +210,26 @@ void parse_fields_from_rule_editor(void) { char final[32]; int i; + char buf[256]; char fname[256]; char rule[2048]; char encoded_rule[4096]; + serv_printf("MSIV putscript|%s|", RULES_SCRIPT); + serv_getln(buf, sizeof buf); + if (buf[0] != '4') { + return; + } + + serv_puts("# THIS SCRIPT WAS AUTOMATICALLY GENERATED BY WEBCIT."); + serv_puts("# "); + serv_puts("# Do not attempt to manually edit it. If you do so,"); + serv_puts("# your changes will be overwritten the next time WebCit"); + serv_puts("# saves its mail filtering rule set. If you really want"); + serv_puts("# to use these rules as the basis for another script,"); + serv_puts("# copy them to another script and save that instead."); + serv_puts(""); + for (i=0; i 0) { for (i=0; i"); escputs(script_name); wprintf("\n"); diff --git a/webcit/tools.c b/webcit/tools.c index 0a0718381..f6ef5088d 100644 --- a/webcit/tools.c +++ b/webcit/tools.c @@ -359,7 +359,7 @@ void sleeeeeeeeeep(int seconds) * \param sourcelen the length of the source data (may contain string terminators) */ -void CtdlEncodeBase64(char *dest, const char *source, size_t sourcelen) +void CtdlEncodeBase64(char *dest, const char *source, size_t sourcelen, int linebreaks) { int i, hiteof = FALSE; int spos = 0; @@ -418,7 +418,7 @@ void CtdlEncodeBase64(char *dest, const char *source, size_t sourcelen) dest[dpos] = 0; } thisline += 4; - if (thisline > 70) { + if ( (linebreaks) && (thisline > 70) ) { dest[dpos++] = '\r'; dest[dpos++] = '\n'; dest[dpos] = 0; @@ -426,7 +426,7 @@ void CtdlEncodeBase64(char *dest, const char *source, size_t sourcelen) } } } - if (thisline > 70) { + if ( (linebreaks) && (thisline > 70) ) { dest[dpos++] = '\r'; dest[dpos++] = '\n'; dest[dpos] = 0; diff --git a/webcit/webcit.h b/webcit/webcit.h index 856854d04..4aef6ac85 100644 --- a/webcit/webcit.h +++ b/webcit/webcit.h @@ -616,7 +616,7 @@ void do_tasks_view(void); void free_calendar_buffer(void); void calendar_summary_view(void); int load_msg_ptrs(char *servcmd, int with_headers); -void CtdlEncodeBase64(char *dest, const char *source, size_t sourcelen); +void CtdlEncodeBase64(char *dest, const char *source, size_t sourcelen, int linebreaks); int CtdlDecodeBase64(char *dest, const char *source, size_t length); void free_attachments(struct wcsession *sess); void free_march_list(struct wcsession *wcf);