summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEduardo Chappa <chappa@washington.edu>2014-02-15 22:27:58 -0700
committerEduardo Chappa <chappa@washington.edu>2014-02-15 22:27:58 -0700
commitaa7d9f18ca61e2fb1998bcaedee9ecdfa93a0728 (patch)
tree72bee5a33580c59500d71f0fd324a0523deea4a0
parent4a1cb9fd5554ef858945894a4dbe36e55f965934 (diff)
downloadalpine-aa7d9f18ca61e2fb1998bcaedee9ecdfa93a0728.tar.xz
* Fixes to documentation to update old washington.edu/alpine site
for patches.freeiz.com/alpine/. Work in progress. * prototype function tigetstr in pico/osdep/terminal.c * folders encoded in modified utf7 are transformed their names to a human readable utf8. * New attempt to fix smime support in Alpine. Messages sent by alpine with or without attachments should validate in all servers and in all folder formats.
-rw-r--r--alpine/Makefile.in1
-rw-r--r--alpine/mailcmd.c37
-rw-r--r--configure.ac2
-rw-r--r--pico/osdep/terminal.c2
-rw-r--r--pico/search.c56
-rw-r--r--pith/folder.c11
-rw-r--r--pith/folder.h1
-rw-r--r--pith/mailcmd.c30
-rw-r--r--pith/pine.hlp2
-rw-r--r--pith/send.c5
-rw-r--r--pith/smime.c159
-rw-r--r--pith/stream.c5
12 files changed, 199 insertions, 112 deletions
diff --git a/alpine/Makefile.in b/alpine/Makefile.in
index 3ed80f64..77d07f13 100644
--- a/alpine/Makefile.in
+++ b/alpine/Makefile.in
@@ -338,7 +338,6 @@ AM_CPPFLAGS = -I@top_builddir@/include -I@top_srcdir@/include -DLOCALEDIR=\"$(lo
CLEANFILES = date.c
all: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) all-recursive
- rm -f date.c
.SUFFIXES:
.SUFFIXES: .c .lo .o .obj
diff --git a/alpine/mailcmd.c b/alpine/mailcmd.c
index 93a08c1f..1d252a38 100644
--- a/alpine/mailcmd.c
+++ b/alpine/mailcmd.c
@@ -3229,10 +3229,12 @@ cmd_expunge(struct pine *state, MAILSTREAM *stream, MSGNO_S *msgmap, int agg)
if(del_count != 0){
int ret;
+ unsigned char *fname = folder_name_decoded((unsigned char *)state->cur_folder);
snprintf(prompt, sizeof(prompt), "Expunge %ld message%s from %.*s", del_count,
plural(del_count), sizeof(prompt)-40,
- pretty_fn(state->cur_folder));
+ pretty_fn((char *) fname));
+ if(fname) fs_give((void **)&fname);
prompt[sizeof(prompt)-1] = '\0';
state->mangled_footer = 1;
@@ -3301,10 +3303,13 @@ cmd_expunge(struct pine *state, MAILSTREAM *stream, MSGNO_S *msgmap, int agg)
refresh_sort(stream, msgmap, SRT_NON);
}
else{
- if(del_count)
+ if(del_count){
+ unsigned char *fname = folder_name_decoded((unsigned char *)state->cur_folder);
q_status_message1(SM_ORDER, 0, 3,
_("No messages expunged from folder \"%s\""),
- pretty_fn(state->cur_folder));
+ pretty_fn((char *) fname));
+ if(fname) fs_give((void **)&fname);
+ }
else if(!prefilter_del_count)
q_status_message(SM_ORDER, 0, 3,
_("No messages marked deleted. No messages expunged."));
@@ -3441,8 +3446,10 @@ void
expunge_and_close_begins(int flags, char *folder)
{
if(!(flags & EC_NO_CLOSE)){
- q_status_message1(SM_INFO, 0, 1, "Closing \"%.200s\"...", folder);
+ unsigned char *fname = folder_name_decoded((unsigned char *)folder);
+ q_status_message1(SM_INFO, 0, 1, "Closing \"%.200s\"...", (char *) fname);
flush_status_messages(1);
+ if(fname) fs_give((void **)&fname);
}
}
@@ -5323,6 +5330,7 @@ broach_folder(int qline, int allow_list, int *notrealinbox, CONTEXT_S **context)
char expanded[MAXPATH+1],
prompt[MAX_SCREEN_COLS+1],
*last_folder, *p;
+ unsigned char *f1, *f2, *f3;
static HISTORY_S *history = NULL;
CONTEXT_S *tc, *tc2;
ESCKEY_S ekey[9];
@@ -5487,10 +5495,29 @@ broach_folder(int qline, int allow_list, int *notrealinbox, CONTEXT_S **context)
}
}
+ /* is there any other way to do this? The point is that we
+ * are trying to hide mutf7 from the user, and use the utf8
+ * equivalent. So we create a variable f to take place of
+ * newfolder, including content and size. f2 is copy of f1
+ * that has to freed. Sigh!
+ */
+ f3 = cpystr(newfolder);
+ f1 = fs_get(sizeof(newfolder));
+ f2 = folder_name_decoded(f3);
+ if(f3) fs_give((void **)&f3);
+ strncpy(f1, f2, sizeof(newfolder));
+ f1[sizeof(newfolder)-1] = '\0';
+ if(f2) fs_give((void **)&f2);
+
flags = OE_APPEND_CURRENT;
- rc = optionally_enter(newfolder, qline, 0, sizeof(newfolder),
+ rc = optionally_enter(f1, qline, 0, sizeof(newfolder),
prompt, ekey, help, &flags);
+ f2 = folder_name_encoded(f1);
+ strncpy(newfolder, f2, sizeof(newfolder));
+ if(f1) fs_give((void **)&f1);
+ if(f2) fs_give((void **)&f2);
+
ps_global->mangled_footer = 1;
switch(rc){
diff --git a/configure.ac b/configure.ac
index 794e1c57..bc0d74a5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -15,7 +15,7 @@ dnl */
AC_PREREQ([2.69])
-AC_REVISION([Rev:8 by chappa@washington.edu])
+AC_REVISION([Rev:9 by chappa@washington.edu])
dnl Alpine Version Number is in $srcdir/VERSION
AC_INIT([alpine],[m4_normalize(m4_include(VERSION))],[chappa@washington.edu])
diff --git a/pico/osdep/terminal.c b/pico/osdep/terminal.c
index 179d6cdc..52c87399 100644
--- a/pico/osdep/terminal.c
+++ b/pico/osdep/terminal.c
@@ -81,7 +81,7 @@ static void tinfodelete(void);
extern int tput();
extern int tputs(char *, int, int (*)(int));
extern char *tgoto(char *, int, int);
-extern char *tigetstr ();
+extern char *tigetstr (char *);
extern int setupterm(char *, int, int *);
extern int tigetnum(char *);
extern int tigetflag(char *);
diff --git a/pico/search.c b/pico/search.c
index 49aaec2d..e017a83a 100644
--- a/pico/search.c
+++ b/pico/search.c
@@ -4,8 +4,8 @@ static char rcsid[] = "$Id: search.c 1266 2009-07-14 18:39:12Z hubert@u.washingt
/*
* ========================================================================
+ * Copyright 2013 Eduardo Chappa
* Copyright 2006-2008 University of Washington
- * Copyright 2013-2014 Eduardo Chappa
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -306,7 +306,7 @@ forwsearch(int f, int n)
x[0] = '\0';
- utf8 = ucs4_to_utf8_cpystr(defpat ? defpat : x);
+ utf8 = sucs4_to_utf8_cpystr(defpat ? defpat : x, bsearch);
/* TRANSLATORS: reporting the result of a failed search */
eml.s = utf8;
emlwrite(_("\"%s\" not found"), &eml);
@@ -448,8 +448,22 @@ replace_pat(UCS *defpat, int *wrapt, int bsearch)
status = replace_all(defpat, lpat, bsearch);
}
else{
+ if(bsearch)
+ curwp->w_doto -= ucs4_strlen(defpat) - 1;
chword(defpat, lpat, bsearch); /* replace word */
- update();
+ /* after substitution the cursor is past the end of the
+ * replaced string, so we backdown in backward search,
+ * to make it appear at the beginning of the replaced string.
+ * We make this choice in case the next search is backward,
+ * because if we put the cursor at the end, the next backward
+ * search might hit the substituted string, and we want to
+ * avoid that, because we probably do not want to substitute
+ * the new string, but old text.
+ */
+ if(bsearch && (lback(curwp->w_dotp) != curbp->b_linep
+ || curwp->w_doto > 0))
+ curwp->w_doto--;
+ supdate(defpat, bsearch);
status = TRUE;
}
@@ -495,14 +509,16 @@ replace_pat(UCS *defpat, int *wrapt, int bsearch)
default:
if(status == ABORT){
emlwrite(_("Replacement Cancelled"), NULL);
+ reverse_all(defpat, bsearch); /* undo reverse buffer and pattern */
pico_refresh(FALSE, 1);
+ reverse_all(defpat, bsearch); /* reverse buffer and pattern */
}
else{
mlerase();
chword(defpat, origpat, bsearch);
}
- update();
+ supdate(defpat, bsearch);
return(FALSE);
}
}
@@ -575,6 +591,7 @@ replace_all(UCS *orig, UCS *repl, int bsearch)
promptp = &prompt[ucs4_strlen(prompt)];
expandp(orig, promptp, NPMT-(promptp-prompt));
+ reverse_all(orig, bsearch); /* reverse for internal use */
prompt[NPMT-1] = '\0';
promptp += ucs4_strlen(promptp);
@@ -599,13 +616,17 @@ replace_all(UCS *orig, UCS *repl, int bsearch)
status = mlyesno(prompt, TRUE); /* ask user */
+ if(bsearch){
+ curwp->w_doto -= ucs4_strlen(realpat) - 1;
+ curwp->w_flag |= WFMOVE;
+ }
if (status == TRUE){
n++;
- chword(realpat, repl, bsearch); /* replace word */
- update();
+ chword(realpat, repl, bsearch); /* replace word */
+ supdate(realpat, bsearch);
}else{
- chword(realpat, realpat, bsearch); /* replace word by itself */
- update();
+ chword(realpat, realpat, bsearch); /* replace word by itself */
+ supdate(realpat, bsearch);
if(status == ABORT){ /* if cancelled return */
eml.s = comatose(n);
emlwrite("Replace All cancelled after %s changes", &eml);
@@ -616,7 +637,7 @@ replace_all(UCS *orig, UCS *repl, int bsearch)
else{
char *utf8;
- utf8 = ucs4_to_utf8_cpystr(orig);
+ utf8 = sucs4_to_utf8_cpystr(orig, bsearch);
if(utf8){
eml.s = utf8;
emlwrite(_("No more matches for \"%s\""), &eml);
@@ -1025,7 +1046,7 @@ forscan(int *wrapt, /* boolean indicating search wrapped */
* first, test to see if we are at the end of the line,
* otherwise start searching on the next character.
*/
- if(curwp->w_doto == llength(curwp->w_dotp)){
+ if(curwp->w_doto == llength(curwp->w_dotp)){
/*
* dot is not on end of a line
* start at 0 offset of the next line
@@ -1034,11 +1055,11 @@ forscan(int *wrapt, /* boolean indicating search wrapped */
stopline = curline = lforw(curwp->w_dotp);
if (curwp->w_dotp == curbp->b_linep)
*wrapt = TRUE;
- }
- else{
+ }
+ else{
stopoff = curoff = curwp->w_doto;
stopline = curline = curwp->w_dotp;
- }
+ }
/* scan each character until we hit the head link record */
@@ -1047,7 +1068,7 @@ forscan(int *wrapt, /* boolean indicating search wrapped */
*/
while (curline){
- if (curline == curbp->b_linep)
+ if(curline == curbp->b_linep)
*wrapt = TRUE;
/* save the current position in case we need to
@@ -1080,10 +1101,10 @@ forscan(int *wrapt, /* boolean indicating search wrapped */
/* scan through patrn for a match */
while (*++patptr != '\0') {
/* advance all the pointers */
- if (matchoff == llength(matchline)) {
+ if (matchoff >= llength(matchline)) {
/* advance past EOL */
matchline = lforw(matchline);
- matchoff = 0;
+ matchoff = 0;
c = '\n';
} else
c = lgetc(matchline, matchoff++).c;
@@ -1100,7 +1121,7 @@ forscan(int *wrapt, /* boolean indicating search wrapped */
/* reset the global "." pointers */
if (leavep == PTEND) { /* at end of string */
curwp->w_dotp = matchline;
- curwp->w_doto = matchoff;
+ curwp->w_doto = matchoff - 1;
}
else { /* at begining of string */
curwp->w_dotp = lastline;
@@ -1109,7 +1130,6 @@ forscan(int *wrapt, /* boolean indicating search wrapped */
curwp->w_flag |= WFMOVE; /* flag that we have moved */
return(TRUE);
-
}
fail:; /* continue to search */
diff --git a/pith/folder.c b/pith/folder.c
index 037bf1ba..da0ea6d5 100644
--- a/pith/folder.c
+++ b/pith/folder.c
@@ -1410,6 +1410,17 @@ unsigned char *folder_name_decoded(unsigned char *mailbox)
return s;
}
+/* mutf7 encoded name of a folder, from its name in utf8.
+ * memory freed by caller.
+ */
+unsigned char *folder_name_encoded(unsigned char *mailbox)
+{
+ unsigned char *s;
+ s = (char *) utf8_to_mutf7(mailbox);
+ if (s == NULL) s = cpystr(mailbox);
+ return s;
+}
+
int
mail_list_in_collection(char **mailbox, char *ref, char *name, char *tail)
{
diff --git a/pith/folder.h b/pith/folder.h
index 6c9f7adf..e3bc30f1 100644
--- a/pith/folder.h
+++ b/pith/folder.h
@@ -130,5 +130,6 @@ void refresh_folder_list(CONTEXT_S *, int, int, MAILSTREAM **);
int folder_complete_internal(CONTEXT_S *, char *, size_t, int *, int);
void folder_delete(int, FLIST *);
unsigned char *folder_name_decoded(unsigned char *);
+unsigned char *folder_name_encoded(unsigned char *);
#endif /* PITH_FOLDER_INCLUDED */
diff --git a/pith/mailcmd.c b/pith/mailcmd.c
index 73be580c..ad3e409e 100644
--- a/pith/mailcmd.c
+++ b/pith/mailcmd.c
@@ -755,7 +755,7 @@ do_broach_folder(char *newfolder, CONTEXT_S *new_context, MAILSTREAM **streamp,
snprintf(status_msg, sizeof(status_msg), "%sOpening \"", do_reopen ? "Re-" : "");
fname = folder_name_decoded((unsigned char *)newfolder);
- strncat(status_msg, pretty_fn(fname ? (char*) fname : newfolder),
+ strncat(status_msg, pretty_fn(fname ? (char *) fname : newfolder),
sizeof(status_msg)-strlen(status_msg) - 2);
if(fname) fs_give((void **)&fname);
status_msg[sizeof(status_msg)-2] = '\0';
@@ -1469,8 +1469,11 @@ expunge_and_close(MAILSTREAM *stream, char **final_msg, long unsigned int flags)
&& context_isambig(folder))){
ret = 'y';
}
- else if(pith_opt_expunge_prompt)
- ret = (*pith_opt_expunge_prompt)(stream, pretty_fn(folder), delete_count);
+ else if(pith_opt_expunge_prompt){
+ unsigned char *fname = folder_name_decoded((unsigned char *)folder);
+ ret = (*pith_opt_expunge_prompt)(stream, pretty_fn((char *)fname), delete_count);
+ if(fname) fs_give((void **) &fname);
+ }
/* get this message back in queue */
if(moved_msg)
@@ -1479,6 +1482,7 @@ expunge_and_close(MAILSTREAM *stream, char **final_msg, long unsigned int flags)
if(ret == 'y'){
long filtered;
+ unsigned char *fname = folder_name_decoded((unsigned char *)folder);
filtered = any_lflagged(sp_msgmap(stream), MN_EXLD);
@@ -1487,13 +1491,14 @@ expunge_and_close(MAILSTREAM *stream, char **final_msg, long unsigned int flags)
no_close ? "" : "Clos",
no_close ? "" : ing,
no_close ? "" : " \"",
- no_close ? "" : pretty_fn(folder),
+ no_close ? "" : pretty_fn((char *)fname),
no_close ? "" : "\". ",
final_msg ? "Kept" : "Keeping",
comatose(stream->nmsgs - filtered - delete_count),
plural(stream->nmsgs - filtered - delete_count),
ing,
long2string(delete_count));
+ if(fname) fs_give((void **)&fname);
if(final_msg)
*final_msg = cpystr(buff2);
else
@@ -1566,11 +1571,12 @@ expunge_and_close(MAILSTREAM *stream, char **final_msg, long unsigned int flags)
}
if(!no_close){
+ unsigned char *fname = folder_name_decoded((unsigned char *)folder);
if(stream->nmsgs){
snprintf(buff2, sizeof(buff2),
"Clos%s folder \"%.*s\". %s%s%s message%s.",
ing,
- sizeof(buff2)-50, pretty_fn(folder),
+ sizeof(buff2)-50, pretty_fn((char *) fname),
final_msg ? "Kept" : "Keeping",
(stream->nmsgs == 1L) ? " single" : " all ",
(stream->nmsgs > 1L)
@@ -1579,8 +1585,9 @@ expunge_and_close(MAILSTREAM *stream, char **final_msg, long unsigned int flags)
}
else{
snprintf(buff2, sizeof(buff2), "Clos%s empty folder \"%.*s\"",
- ing, sizeof(buff2)-50, pretty_fn(folder));
+ ing, sizeof(buff2)-50, pretty_fn((char *) fname));
}
+ if(fname) fs_give((void **)&fname);
if(final_msg)
*final_msg = cpystr(buff2);
@@ -1626,7 +1633,9 @@ expunge_and_close(MAILSTREAM *stream, char **final_msg, long unsigned int flags)
delete_count++;
if(delete_count && pith_opt_expunge_prompt){
- ret = (*pith_opt_expunge_prompt)(stream, pretty_fn(folder), delete_count);
+ unsigned char *fname = folder_name_decoded((unsigned char *)folder);
+ ret = (*pith_opt_expunge_prompt)(stream, pretty_fn((char *) fname), delete_count);
+ if(fname) fs_give((void **)&fname);
if(ret == 'y'){
char seq[64];
@@ -1639,10 +1648,13 @@ expunge_and_close(MAILSTREAM *stream, char **final_msg, long unsigned int flags)
if(F_ON(F_NEWS_CROSS_DELETE, ps_global))
cross_delete_crossposts(stream);
}
- else
+ else{
+ unsigned char *fname = folder_name_decoded((unsigned char *)folder);
snprintf(buff2, sizeof(buff2),
"Clos%s read-only folder \"%.*s\". No changes to save",
- ing, sizeof(buff2)-60, pretty_fn(folder));
+ ing, sizeof(buff2)-60, pretty_fn((char *) fname));
+ if(fname) fs_give((void **)&fname);
+ }
if(final_msg)
*final_msg = cpystr(buff2);
diff --git a/pith/pine.hlp b/pith/pine.hlp
index b2ac8b16..4cca9be0 100644
--- a/pith/pine.hlp
+++ b/pith/pine.hlp
@@ -140,7 +140,7 @@ with help text for the config screen and the composer that didn't have any
reasonable place to be called from.
Dummy change to get revision in pine.hlp
============= h_revision =================
-Alpine Commit 44 2014-02-09 21:12:14
+Alpine Commit 45 2014-02-15 22:27:53
============= h_news =================
<HTML>
<HEAD>
diff --git a/pith/send.c b/pith/send.c
index 4af84ebe..3f21f1f3 100644
--- a/pith/send.c
+++ b/pith/send.c
@@ -4287,6 +4287,11 @@ pine_rfc822_output_body(struct mail_bodystruct *body, soutr_t f, void *s)
/* output trailing cookie */
snprintf (t = tmp, sizeof(tmp), "--%s--",cookie);
tmp[sizeof(tmp)-1] = '\0';
+#ifdef SMIME
+ if(ps_global->smime && ps_global->smime->do_sign
+ && strlen(tmp) < sizeof(tmp)-2)
+ strncat(tmp, "\r\n", 2);
+#endif
if(lmc.so && !lmc.all_written){
so_puts(lmc.so, t);
so_puts(lmc.so, "\015\012");
diff --git a/pith/smime.c b/pith/smime.c
index e34cfb6b..8d7bbd27 100644
--- a/pith/smime.c
+++ b/pith/smime.c
@@ -56,7 +56,6 @@ static int app_RAND_write_file(const char *file);
static void smime_init(void);
static const char *openssl_error_string(void);
static void create_local_cache(char *base, BODY *b);
-static BIO *raw_part_to_bio(long msgno, const char *section);
static long rfc822_output_func(void *b, char *string);
static int load_private_key(PERSONAL_CERT *pcert);
static void setup_pkcs7_body_for_signature(BODY *b, char *description,
@@ -1469,50 +1468,6 @@ end:
/*
- * Plonk the contents (mime headers and body) of the given
- * section of a message to a BIO_s_mem BIO object.
- */
-static BIO *
-raw_part_to_bio(long msgno, const char *section)
-{
- unsigned long len;
- char *text;
- BIO *bio;
-
- bio = BIO_new(BIO_s_mem());
-
- if(bio){
-
- (void) BIO_reset(bio);
-
- /* First grab headers of the chap */
- text = mail_fetch_mime(ps_global->mail_stream, msgno, (char*) section, &len, 0);
-
- if(text){
- BIO_write(bio, text, len);
-
- /** Now grab actual body */
- text = mail_fetch_body (ps_global->mail_stream, msgno, (char*) section, &len, 0);
- if(text){
- BIO_write(bio, text, len);
- }
- else{
- BIO_free(bio);
- bio = NULL;
- }
-
- }
- else{
- BIO_free(bio);
- bio = NULL;
- }
- }
-
- return bio;
-}
-
-
-/*
Get (and decode) the body of the given section of msg
*/
static STORE_S*
@@ -1684,6 +1639,40 @@ free_smime_body_sparep(void **sparep)
}
}
+/* Big comment, explaining the mess that exists out there
+
+ When Alpine sends a message, it constructs that message, computes the
+ signature, but then it forgets the message it signed and reconstructs it
+ again. Since it signs a message containing a notice about "mime aware
+ tools", but it does not send that we do not include that in the part that
+ is signed, and that takes care of much of the problems.
+
+ Another problem is what is received from the servers. All servers tested
+ seem to transmit the message that was signed intact and Alpine can check
+ the signature correctly. That is not a problem. The problem arises when
+ the message includes attachments. In this case different servers send
+ different things, so it will be up to us to figure out what is the text
+ that was actually signed. Confused? here is the story:
+
+ When a message containing and attachment is sent by Alpine, UW-IMAP,
+ Panda-IMAP, Gmail, and local reading of folders send exactly the message
+ that was sent by Alpine, but GMX.com, Exchange, and probably other servers
+ add a trailing \r\n in the message, so when validating the signature,
+ these messages will not validate. There are several things that can be
+ done.
+
+ 1. Add a trailing \r\n to any message that contains attachments, sign that
+ and send that. In this way, all messages will validate with all
+ servers.
+
+ 2. Compatibility mode: If a message has an attachment, contains a trailing
+ \r\n and does not validate (sent by an earlier version of Alpine),
+ remove the trailing \r\n and try to revalidate again.
+
+ 3. We do not add \r\n to validate a message that we sent, because that
+ would only work in Alpine, and not in any other client. That would not
+ be a good thing to do.
+ */
/*
* Given a multipart body of type multipart/signed, attempt to verify it.
@@ -1696,55 +1685,77 @@ do_detached_signature_verify(BODY *b, long msgno, char *section)
BIO *in = NULL;
PART *p;
int result, modified_the_body = 0;
- char newSec[100];
+ unsigned long mimelen, bodylen;
+ char newSec[100], *mimetext, *bodytext;
char *what_we_did;
dprint((9, "do_detached_signature_verify(msgno=%ld type=%d subtype=%s section=%s)", msgno, b->type, b->subtype ? b->subtype : "NULL", (section && *section) ? section : (section != NULL) ? "Top" : "NULL"));
smime_init();
snprintf(newSec, sizeof(newSec), "%s%s1", section ? section : "", (section && *section) ? "." : "");
- in = raw_part_to_bio(msgno, newSec);
- if(in){
+ mimetext = mail_fetch_mime(ps_global->mail_stream, msgno, (char*) newSec, &mimelen, 0);
- snprintf(newSec, sizeof(newSec), "%s%s2", section ? section : "", (section && *section) ? "." : "");
- p7 = get_pkcs7_from_part(msgno, newSec);
+ if(mimetext)
+ bodytext = mail_fetch_body (ps_global->mail_stream, msgno, (char*) newSec, &bodylen, 0);
- if(!p7)
- goto end;
+ if (mimetext == NULL || bodytext == NULL)
+ return modified_the_body;
- result = do_signature_verify(p7, in, NULL);
+ snprintf(newSec, sizeof(newSec), "%s%s2", section ? section : "", (section && *section) ? "." : "");
- if(b->subtype)
- fs_give((void**) &b->subtype);
+ if((p7 = get_pkcs7_from_part(msgno, newSec)) == NULL)
+ return modified_the_body;
- b->subtype = cpystr(OUR_PKCS7_ENCLOSURE_SUBTYPE);
- b->encoding = ENC8BIT;
+ /* first try with what get got */
+ if((in = BIO_new(BIO_s_mem())) == NULL)
+ return modified_the_body;
- if(b->description)
- fs_give ((void**) &b->description);
+ (void) BIO_reset(in);
+ BIO_write(in, mimetext, mimelen);
+ BIO_write(in, bodytext, bodylen);
- what_we_did = result ? _("This message was cryptographically signed.") :
- _("This message was cryptographically signed but the signature could not be verified.");
+ /* Try compatibility with the past and check if this message
+ validates when we remove the last two characters
+ */
+ if(((result = do_signature_verify(p7, in, NULL)) == 0)
+ && bodylen > 2
+ && (strncmp(bodytext+bodylen-2,"\r\n", 2) == 0)){
+ BIO_free(in);
+ if((in = BIO_new(BIO_s_mem())) == NULL)
+ return modified_the_body;
- b->description = cpystr(what_we_did);
+ (void) BIO_reset(in);
+ BIO_write(in, mimetext, mimelen);
+ BIO_write(in, bodytext, bodylen-2);
- b->sparep = p7;
- p7 = NULL;
+ result = do_signature_verify(p7, in, NULL);
+ }
- p = b->nested.part;
-
- /* p is signed plaintext */
- if(p && p->next)
- mail_free_body_part(&p->next); /* hide the pkcs7 from the viewer */
+ BIO_free(in);
+ if(b->subtype)
+ fs_give((void**) &b->subtype);
- BIO_free(in);
+ b->subtype = cpystr(OUR_PKCS7_ENCLOSURE_SUBTYPE);
+ b->encoding = ENC8BIT;
- modified_the_body = 1;
- }
+ if(b->description)
+ fs_give ((void**) &b->description);
-end:
- PKCS7_free(p7);
+ what_we_did = result ? _("This message was cryptographically signed.") :
+ _("This message was cryptographically signed but the signature could not be verified.");
+
+ b->description = cpystr(what_we_did);
+
+ b->sparep = p7;
+
+ p = b->nested.part;
+
+ /* p is signed plaintext */
+ if(p && p->next)
+ mail_free_body_part(&p->next); /* hide the pkcs7 from the viewer */
+
+ modified_the_body = 1;
return modified_the_body;
}
diff --git a/pith/stream.c b/pith/stream.c
index e96e6089..5201a440 100644
--- a/pith/stream.c
+++ b/pith/stream.c
@@ -3264,7 +3264,7 @@ streams_died(void)
int rv = 0;
int i;
MAILSTREAM *m;
- char *folder;
+ unsigned char *folder;
for(i = 0; i < ps_global->s_pool.nstream; i++){
m = ps_global->s_pool.streams[i];
@@ -3273,7 +3273,7 @@ streams_died(void)
if(!sp_noticed_dead_stream(m)){
rv++;
sp_set_noticed_dead_stream(m, 1);
- folder = STREAMNAME(m);
+ folder = folder_name_decoded((unsigned char *)STREAMNAME(m));
q_status_message1(SM_ORDER | SM_DING, 3, 3,
_("MAIL FOLDER \"%s\" CLOSED DUE TO ACCESS ERROR"),
short_str(pretty_fn(folder) ? pretty_fn(folder) : "?",
@@ -3287,6 +3287,7 @@ streams_died(void)
if(pith_opt_icon_text)
(*pith_opt_icon_text)(tmp_20k_buf, IT_MCLOSED);
}
+ if(folder) fs_give((void **)&folder);
}
}
else{