Re: What happened to strict_mime?
On Wed, Mar 21, 2007 at 11:25:25PM +0900,
TAKIZAWA Takashi wrote:
> On Wed, Mar 21, 2007 at 11:11:40PM +0900,
> TAKIZAWA Takashi wrote:
>
> > The attached patch is the one that the following correction was done.
> > - Remove the option $ignore_linear_white_space.
> > - By default, replace linear-white-space between encoded-word
> > and text to a single space.
> > - Clean up the code.
>
> The mistake is found a little.
> Please disregard this patch.
The attached patch is the corrected one.
--
TAKIZAWA Takashi
http://www.emaillab.org/
diff -r b0172175cc89 init.h
--- a/init.h Tue Mar 20 13:39:29 2007 -0700
+++ b/init.h Wed Mar 21 21:05:39 2007 +0900
@@ -850,13 +850,6 @@ struct option_t MuttVars[] = {
** Specifies the hostname to use after the ``@'' in local e-mail
** addresses. This overrides the compile time definition obtained from
** /etc/resolv.conf.
- */
- { "ignore_linear_white_space", DT_BOOL, R_NONE, OPTIGNORELWS, 0 },
- /*
- ** .pp
- ** This option replaces linear-white-space between encoded-word
- ** and *text to a single space to prevent the display of MIME-encoded
- ** ``Subject'' field from being divided into multiple lines.
*/
{ "ignore_list_reply_to", DT_BOOL, R_NONE, OPTIGNORELISTREPLYTO, 0 },
/*
diff -r b0172175cc89 mutt.h
--- a/mutt.h Tue Mar 20 13:39:29 2007 -0700
+++ b/mutt.h Wed Mar 21 21:05:40 2007 +0900
@@ -372,7 +372,6 @@ enum
OPTHIDETHREADSUBJECT,
OPTHIDETOPLIMITED,
OPTHIDETOPMISSING,
- OPTIGNORELWS,
OPTIGNORELISTREPLYTO,
#ifdef USE_IMAP
OPTIMAPCHECKSUBSCRIBED,
diff -r b0172175cc89 rfc2047.c
--- a/rfc2047.c Tue Mar 20 13:39:29 2007 -0700
+++ b/rfc2047.c Wed Mar 21 23:35:49 2007 +0900
@@ -47,6 +47,8 @@
#define HSPACE(x) ((x) == '\0' || (x) == ' ' || (x) == '\t')
#define CONTINUATION_BYTE(c) (((c) & 0xc0) == 0x80)
+
+#define LWSP(x) strchr(" \t\r\n", x)
extern char RFC822Specials[];
@@ -748,54 +750,13 @@ static const char *find_encoded_word (co
return 0;
}
-/* return length of linear-white-space */
-static size_t lwslen (const char *s, size_t n)
-{
- const char *p = s;
- size_t len = n;
-
- if (n <= 0)
- return 0;
-
- for (; p < s + n; p++)
- if (!strchr (" \t\r\n", *p))
- {
- len = (size_t)(p - s);
- break;
- }
- if (strchr ("\r\n", *(p-1))) /* LWS doesn't end with CRLF */
- len = (size_t)0;
- return len;
-}
-
-/* return length of linear-white-space : reverse */
-static size_t lwsrlen (const char *s, size_t n)
-{
- const char *p = s + n - 1;
- size_t len = n;
-
- if (n <= 0)
- return 0;
-
- if (strchr ("\r\n", *p)) /* LWS doesn't end with CRLF */
- return (size_t)0;
-
- for (; p >= s; p--)
- if (!strchr (" \t\r\n", *p))
- {
- len = (size_t)(s + n - 1 - p);
- break;
- }
- return len;
-}
-
/* try to decode anything that looks like a valid RFC2047 encoded
* header field, ignoring RFC822 parsing rules
*/
void rfc2047_decode (char **pd)
{
- const char *p, *q;
- size_t m, n;
+ const char *p, *q, *r;
+ size_t n;
int found_encoded = 0;
char *d0, *d;
const char *s = *pd;
@@ -812,15 +773,16 @@ void rfc2047_decode (char **pd)
if (!(p = find_encoded_word (s, &q)))
{
/* no encoded words */
- if (option (OPTIGNORELWS))
+ if (found_encoded && LWSP (*s))
{
- n = mutt_strlen (s);
- if (found_encoded && (m = lwslen (s, n)) != 0)
- {
- if (m != n)
- *d = ' ', d++, dlen--;
- s += m;
- }
+ while (*s && LWSP (*s))
+ s++;
+ if (dlen > 0)
+ {
+ *d = *s ? ' ' : '\n';
+ d++;
+ dlen--;
+ }
}
if (AssumedCharset && *AssumedCharset)
{
@@ -842,38 +804,36 @@ void rfc2047_decode (char **pd)
break;
}
- if (p != s)
- {
- n = (size_t) (p - s);
- /* ignore spaces between encoded word
- * and linear-white-space between encoded word and *text */
- if (option (OPTIGNORELWS))
+ if (p != s && found_encoded && LWSP (*s))
+ {
+ while (*s && LWSP (*s))
+ s++;
+ if (p != s && dlen > 0)
{
- if (found_encoded && (m = lwslen (s, n)) != 0)
- {
- if (m != n)
- *d = ' ', d++, dlen--;
- n -= m, s += m;
- }
-
- if ((m = n - lwsrlen (s, n)) != 0)
- {
- if (m > dlen)
- m = dlen;
- memcpy (d, s, m);
- d += m;
- dlen -= m;
- if (m != n)
- *d = ' ', d++, dlen--;
- }
+ *d = ' ';
+ d++;
+ dlen--;
}
- else if (!found_encoded || strspn (s, " \t\r\n") != n)
+ }
+
+ if (p != s) {
+ r = p - 1;
+ if (LWSP (*r))
{
- if (n > dlen)
- n = dlen;
- memcpy (d, s, n);
- d += n;
- dlen -= n;
+ while (s < r && LWSP (*r))
+ r--;
+ }
+ n = (size_t) (r - s + 1);
+ if (n > dlen)
+ n = dlen;
+ memcpy (d, s, n);
+ d += n;
+ dlen -= n;
+ if (LWSP (*(p - 1)) && dlen > 0)
+ {
+ *d = ' ';
+ d++;
+ dlen--;
}
}