"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "libs/maildir/maildirinfo.c" between
sqwebmail-5.9.3.tar.bz2 and sqwebmail-6.0.0.tar.bz2

About: SqWebMail is a CGI Webmail client for Maildir mailboxes (module of the Courier mail server).

maildirinfo.c  (sqwebmail-5.9.3.tar.bz2):maildirinfo.c  (sqwebmail-6.0.0.tar.bz2)
skipping to change at line 420 skipping to change at line 420
{ {
free(ifs.maildir); free(ifs.maildir);
ifs.maildir=NULL; ifs.maildir=NULL;
} }
return 0; return 0;
} }
/***************************************************************************/ /***************************************************************************/
/* /*
** Maildir folders are named in IMAP-compatible modified-UTF7 encoding, ** Maildir folders are named in IMAP-compatible modified-UTF8 encoding,
** with periods as hierarchy delimiters. One exception: ".", "/", "~", and ** with periods as hierarchy delimiters. One exception: ".", "/", "~", and
** ":" are also encoded using modified-UTF7, making folder names that contain ** ":" are also encoded using modified-UTF8, making folder names that contain
** those characters incompatible with IMAP. ** those characters incompatible with IMAP.
** **
** smaptoUtf7 crates a modified-UTF7-encoded folder name from a vector ** smap_to_utf8 crates a modified-UTF8-encoded folder name from a vector
** of UTF-8 words. ** of UTF-8 words.
** **
** input: "INBOX" "a" "b" ** input: "INBOX" "a" "b"
** output: "INBOX.a.b" ** output: "INBOX.a.b"
** **
*/ */
static char *smaptoUtf7(char **ptr) static char *smap_to_utf8(char **ptr)
{ {
char *f=NULL; char *f=NULL;
char *n; char *n;
while ((n=*ptr++) != NULL && *n) while ((n=*ptr++) != NULL && *n)
{ {
char *p=unicode_convert_tobuf(n, "utf-8", char *p=unicode_convert_tobuf(n, "utf-8",
unicode_x_imap_modutf7 " ./~:", unicode_x_smap_modutf8,
NULL); NULL);
if (!p) if (!p)
{ {
if (f) if (f)
free(f); free(f);
return NULL; return NULL;
} }
n= f ? realloc(f, strlen(f)+strlen(p)+2):malloc(strlen(p)+1); n= f ? realloc(f, strlen(f)+strlen(p)+2):malloc(strlen(p)+1);
skipping to change at line 473 skipping to change at line 473
f=strcpy(n, p); f=strcpy(n, p);
free(p); free(p);
} }
if (!f) if (!f)
errno=EINVAL; errno=EINVAL;
return f; return f;
} }
/* /*
** Legacy IMAP creates maildir folders using modified-UTF7. ** Convert modified-UTF8 folder name into an array of UTF-8 words, that
**
** Convert modified-UTF7 folder name into an array of UTF-8 words, that
** represent a folder name. ** represent a folder name.
*/ */
char **maildir_smapfn_fromutf7(const char *modutf7) char **maildir_smapfn_fromutf8(const char *modutf8)
{ {
char *p=strdup(modutf7), *q; char *p=strdup(modutf8), *q;
size_t n, i; size_t n, i;
char **fn; char **fn;
if (!p) if (!p)
return NULL; return NULL;
n=1; n=1;
for (i=0; p[i]; i++) for (i=0; p[i]; i++)
if (p[i] == '.' && p[i+1] && p[i+1] != '.') if (p[i] == '.' && p[i+1] && p[i+1] != '.')
{ {
skipping to change at line 515 skipping to change at line 513
do do
{ {
for (i=0; q[i]; i++) for (i=0; q[i]; i++)
if (q[i] == '.' && q[i+1] && q[i+1] != '.') if (q[i] == '.' && q[i+1] && q[i+1] != '.')
{ {
q[i++]=0; q[i++]=0;
break; break;
} }
fn[n]=unicode_convert_tobuf(q, fn[n]=unicode_convert_tobuf(q,
unicode_x_imap_modutf7 " ./~:", unicode_x_smap_modutf8,
"utf-8", NULL); "utf-8", NULL);
q += i; q += i;
if (!fn[n]) if (!fn[n])
{ {
while (n) while (n)
free(fn[--n]); free(fn[--n]);
free(fn); free(fn);
free(p); free(p);
return NULL; return NULL;
} }
skipping to change at line 560 skipping to change at line 558
char **fn; char **fn;
struct get_existing_folder_info *gefi= struct get_existing_folder_info *gefi=
(struct get_existing_folder_info *)vp; (struct get_existing_folder_info *)vp;
size_t i; size_t i;
size_t j; size_t j;
if (gefi->pathname) if (gefi->pathname)
return; return;
fn=maildir_smapfn_fromutf7(f); fn=maildir_smapfn_fromutf8(f);
if (!fn) if (!fn)
{ {
perror(f); perror(f);
return; return;
} }
for (i=0; gefi->fn[i]; i++) for (i=0; gefi->fn[i]; i++)
if (fn[i] == NULL || strcmp(fn[i], gefi->fn[i])) if (fn[i] == NULL || strcmp(fn[i], gefi->fn[i]))
{ {
maildir_smapfn_free(fn); maildir_smapfn_free(fn);
skipping to change at line 603 skipping to change at line 601
gefi->pathname[j]=0; gefi->pathname[j]=0;
} }
static char *smap_path(const char *homedir, static char *smap_path(const char *homedir,
char **words) /* words[0] better be INBOX! */ char **words) /* words[0] better be INBOX! */
{ {
struct get_existing_folder_info gefi; struct get_existing_folder_info gefi;
char *n, *p; char *n, *p;
struct stat stat_buf; struct stat stat_buf;
if ((n=smaptoUtf7(words)) == NULL) if ((n=smap_to_utf8(words)) == NULL)
return NULL; return NULL;
p=maildir_name2dir(homedir, n); p=maildir_name2dir(homedir, n);
if (!p) if (!p)
{ {
free(n); free(n);
return NULL; return NULL;
} }
 End of changes. 11 change blocks. 
15 lines changed or deleted 13 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)