aboutsummaryrefslogtreecommitdiffstats
path: root/camel
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2001-06-28 06:14:20 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2001-06-28 06:14:20 +0800
commit016826bc8a947b2ea0308971cb1ca355bef4aa47 (patch)
tree2db4c482f1fa79988958a2c256a7e657bfcd4f9e /camel
parent4cbcd49a8bed07221be190b80e84e23f0ad7d449 (diff)
downloadgsoc2013-evolution-016826bc8a947b2ea0308971cb1ca355bef4aa47.tar
gsoc2013-evolution-016826bc8a947b2ea0308971cb1ca355bef4aa47.tar.gz
gsoc2013-evolution-016826bc8a947b2ea0308971cb1ca355bef4aa47.tar.bz2
gsoc2013-evolution-016826bc8a947b2ea0308971cb1ca355bef4aa47.tar.lz
gsoc2013-evolution-016826bc8a947b2ea0308971cb1ca355bef4aa47.tar.xz
gsoc2013-evolution-016826bc8a947b2ea0308971cb1ca355bef4aa47.tar.zst
gsoc2013-evolution-016826bc8a947b2ea0308971cb1ca355bef4aa47.zip
Use the new header_address_fold.
2001-06-27 Jeffrey Stedfast <fejj@ximian.com> * camel-internet-address.c (camel_internet_address_encode_address): Use the new header_address_fold. * camel-mime-utils.c: Removed some old #if 0'd code of mine. (rfc2047_encode_word): If enclen is 0, don't write an encoded word token (=?iso-8859-7?Q??= would be an invalid token). (header_address_fold): New function to wrap address headers - header_fold() was force-wrapping rfc2047 encoded words which was making the test suite fail. The *real* solution, however, is to not create rfc2047 encoded words longer than 72 chars. svn path=/trunk/; revision=10545
Diffstat (limited to 'camel')
-rw-r--r--camel/ChangeLog14
-rw-r--r--camel/camel-internet-address.c2
-rw-r--r--camel/camel-mime-utils.c119
-rw-r--r--camel/camel-mime-utils.h1
4 files changed, 53 insertions, 83 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index c5dc946aac..7c71fc8972 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,17 @@
+2001-06-27 Jeffrey Stedfast <fejj@ximian.com>
+
+ * camel-internet-address.c
+ (camel_internet_address_encode_address): Use the new
+ header_address_fold.
+
+ * camel-mime-utils.c: Removed some old #if 0'd code of mine.
+ (rfc2047_encode_word): If enclen is 0, don't write an encoded word
+ token (=?iso-8859-7?Q??= would be an invalid token).
+ (header_address_fold): New function to wrap address headers -
+ header_fold() was force-wrapping rfc2047 encoded words which was
+ making the test suite fail. The *real* solution, however, is to
+ not create rfc2047 encoded words longer than 72 chars.
+
2001-06-26 Jeffrey Stedfast <fejj@ximian.com>
* camel-filter-driver.c (open_folder): Since we want an error
diff --git a/camel/camel-internet-address.c b/camel/camel-internet-address.c
index 5a72916ca9..c1ca4f8430 100644
--- a/camel/camel-internet-address.c
+++ b/camel/camel-internet-address.c
@@ -422,7 +422,7 @@ camel_internet_address_encode_address(int *inlen, const char *real, const char *
if (name && name[0]) {
if (strlen(name) + len > CAMEL_FOLD_SIZE) {
- char *folded = header_fold(name, len);
+ char *folded = header_address_fold(name, len);
char *last;
g_string_append(out, folded);
g_free(folded);
diff --git a/camel/camel-mime-utils.c b/camel/camel-mime-utils.c
index db8558cb18..802514bf02 100644
--- a/camel/camel-mime-utils.c
+++ b/camel/camel-mime-utils.c
@@ -1221,22 +1221,24 @@ rfc2047_encode_word(GString *outstring, const char *in, int len, const char *typ
}
inlen -= (inptr - p);
}
-
+
enclen = out-buffer;
-
- /* create token */
- out = ascii;
- if (first)
- first = 0;
- else
- *out++ = ' ';
- out += sprintf(out, "=?%s?Q?", type);
- out += quoted_encode(buffer, enclen, out, safemask);
- sprintf(out, "?=");
-
- d(printf("converted part = %s\n", ascii));
-
- g_string_append(outstring, ascii);
+
+ if (enclen) {
+ /* create token */
+ out = ascii;
+ if (first)
+ first = 0;
+ else
+ *out++ = ' ';
+ out += sprintf (out, "=?%s?Q?", type);
+ out += quoted_encode (buffer, enclen, out, safemask);
+ sprintf (out, "?=");
+
+ d(printf("converted part = %s\n", ascii));
+
+ g_string_append (outstring, ascii);
+ }
}
if (ic != (iconv_t) -1) {
@@ -1494,11 +1496,12 @@ header_encode_phrase_get_words (const unsigned char *in)
return words;
}
-static void
+static gboolean
header_encode_phrase_merge_words (GList **wordsp)
{
GList *wordl, *nextl, *words = *wordsp;
struct _phrase_word *word, *next;
+ gboolean merged = FALSE;
/* scan the list, checking for words of similar types that can be merged */
wordl = words;
@@ -1518,6 +1521,8 @@ header_encode_phrase_merge_words (GList **wordsp)
words = g_list_remove_link (words, nextl);
g_free (next);
nextl = g_list_next (wordl);
+
+ merged = TRUE;
} else {
/* if it is going to be too long, make sure we include the
separating whitespace */
@@ -1533,6 +1538,8 @@ header_encode_phrase_merge_words (GList **wordsp)
}
*wordsp = words;
+
+ return merged;
}
/* encodes a phrase sequence (different quoting/encoding rules to strings) */
@@ -1551,7 +1558,7 @@ header_encode_phrase (const unsigned char *in)
if (!words)
return NULL;
- header_encode_phrase_merge_words (&words);
+ while (header_encode_phrase_merge_words (&words));
out = g_string_new ("");
@@ -3662,47 +3669,14 @@ header_address_list_format(struct _header_address *a)
return ret;
}
-#if 0
-static const char *
-header_fold_next_space (const char *in)
-{
- register const char *inptr = in;
- gboolean escaped = FALSE;
-
- if (is_lwsp (*inptr))
- return inptr;
-
- do {
- if (*inptr == '\\') {
- escaped = TRUE;
- } else if (*inptr == '"' && !escaped) {
- /* find the end of this quoted section */
- for (inptr++; *inptr; inptr++) {
- if (*inptr == '"' && *(inptr-1) != '\\')
- break;
- }
- } else {
- escaped = FALSE;
- }
-
- inptr++;
- } while (*inptr && !is_lwsp (*inptr));
-
- if (*inptr)
- return inptr;
- else
- return NULL;
-}
-
-/* I wonder if this might be better for folding headers? */
char *
-header_fold (const char *in, int headerlen, gboolean force)
+header_address_fold (const char *in, int headerlen)
{
- const char *inptr = in, *space, *p, *n;
- gboolean needunfold = FALSE;
int len, outlen, i;
+ const char *inptr = in, *space, *p, *n;
GString *out;
char *ret;
+ int needunfold = FALSE;
if (in == NULL)
return NULL;
@@ -3712,19 +3686,19 @@ header_fold (const char *in, int headerlen, gboolean force)
p = in;
while (*p) {
n = strchr (p, '\n');
- if (n == NULL)
- n = p + strlen (p);
- else
- needunfold = TRUE;
+ if (n == NULL) {
+ len += strlen (p);
+ break;
+ }
- len += n - p;
+ needunfold = TRUE;
+ len += n-p;
if (len >= CAMEL_FOLD_SIZE)
break;
len = 0;
p = n + 1;
}
-
if (len < CAMEL_FOLD_SIZE)
return g_strdup (in);
@@ -3735,18 +3709,14 @@ header_fold (const char *in, int headerlen, gboolean force)
out = g_string_new ("");
outlen = headerlen + 2;
while (*inptr) {
- if (force)
- space = strchr (inptr, ' ');
- else
- space = header_fold_next_space (inptr);
-
+ space = strchr (inptr, ' ');
if (space) {
len = space - inptr + 1;
} else {
len = strlen (inptr);
}
- d(printf ("next word '%.*s'\n", len, inptr));
+ d(printf("next word '%.*s'\n", len, inptr));
if (outlen + len > CAMEL_FOLD_SIZE) {
d(printf("outlen = %d wordlen = %d\n", outlen, len));
@@ -3755,28 +3725,15 @@ header_fold (const char *in, int headerlen, gboolean force)
g_string_truncate (out, out->len-1);
g_string_append (out, "\n\t");
outlen = 1;
-
- if (force) {
- /* check for very long words, just cut them up */
- while (outlen + len > CAMEL_FOLD_SIZE) {
- for (i = 0; i < CAMEL_FOLD_SIZE - outlen; i++)
- g_string_append_c (out, inptr[i]);
- inptr += CAMEL_FOLD_SIZE - outlen;
- len -= CAMEL_FOLD_SIZE - outlen;
- g_string_append (out, "\n\t");
- outlen = 1;
- }
- }
}
outlen += len;
-
- for (i = 0; i < len; i++)
+ for (i = 0; i < len; i++) {
g_string_append_c (out, inptr[i]);
+ }
inptr += len;
}
-
ret = out->str;
g_string_free (out, FALSE);
@@ -3785,8 +3742,6 @@ header_fold (const char *in, int headerlen, gboolean force)
return ret;
}
-#endif
-
/* simple header folding */
/* will work even if the header is already folded */
diff --git a/camel/camel-mime-utils.h b/camel/camel-mime-utils.h
index 08755c47b1..c32485d000 100644
--- a/camel/camel-mime-utils.h
+++ b/camel/camel-mime-utils.h
@@ -145,6 +145,7 @@ void header_raw_clear(struct _header_raw **list);
char *header_raw_check_mailing_list(struct _header_raw **list);
/* fold a header */
+char *header_address_fold(const char *in, int headerlen);
char *header_fold(const char *in, int headerlen);
char *header_unfold(const char *in);