cruxports/mblaze/mblaze-fofl.patch
2022-02-05 15:39:19 -05:00

102 lines
2.7 KiB
Diff

--- mblaze-1.1/mmime.c 2021-01-14 10:45:22.000000000 -0500
+++ mblaze-1.1f/mmime.c 2021-06-12 20:35:09.994308179 -0400
@@ -134,6 +134,68 @@
return linelen;
}
+size_t
+gen_flowd(uint8_t *s, off_t size, size_t maxlinelen, size_t linelen)
+{
+ off_t i;
+ int header = linelen > 0;
+
+ for (i = 0; i < size; i++) {
+ // inspect utf8 sequence to not wrap in between multibyte
+ int mb;
+ if ((s[i] & 0x80) == 0) mb = 3;
+ else if ((s[i] & 0xc0) == 0x80) mb = 3;
+ else if ((s[i] & 0xe0) == 0xc0) mb = 6;
+ else if ((s[i] & 0xf0) == 0xe0) mb = 9;
+ else if ((s[i] & 0xf8) == 0xf0) mb = 12;
+ else mb = 3;
+
+ if (linelen >= maxlinelen-mb-!!header) {
+ linelen = 0;
+ if (header) {
+ printf("\n");
+ } else {
+ puts(" ");
+ }
+ }
+
+ if ((s[i] > 126) ||
+ (linelen == 0 &&
+ (strncmp((char *)s, "From ", 5) == 0 ||
+ (s[i] == '.' && i+1 < size &&
+ (s[i+1] == '\n' || s[i+1] == '\r'))))) {
+ putc_unlocked(s[i], stdout);
+ linelen ++;
+ } else if (header &&
+ (s[i] == '\n' || s[i] == '\t' || s[i] == '_')) {
+ putc_unlocked(s[i], stdout);
+ linelen ++;
+ } else if (header && s[i] == ' ') {
+ putc_unlocked('_', stdout);
+ linelen++;
+ } else if (s[i] < 33 && s[i] != '\n') {
+ if ((s[i] == ' ' || s[i] == '\t') &&
+ i+1 < size &&
+ (s[i+1] != '\n' && s[i+1] != '\r')) {
+ putc_unlocked(s[i], stdout);
+ linelen++;
+ } else {
+ putc_unlocked(s[i], stdout);
+ linelen++;
+ }
+ } else if (s[i] == '\n') {
+ putc_unlocked('\n', stdout);
+ linelen = 0;
+ } else {
+ putc_unlocked(s[i], stdout);
+ linelen++;
+ }
+ }
+ if (linelen > 0 && !header)
+ puts("\n");
+ return linelen;
+}
+
static const char *
basenam(const char *s)
{
@@ -401,8 +463,8 @@
inheader = 0;
printf("MIME-Version: 1.0\n");
if (rflag) {
- printf("Content-Type: text/plain; charset=UTF-8\n");
- printf("Content-Transfer-Encoding: quoted-printable\n\n");
+ printf("Content-Type: text/plain; charset=US-ASCII; format=flowed\n");
+ printf("Content-Transfer-Encoding: 7bit\n\n");
} else {
printf("Content-Type: %s; boundary=\"%s\"\n", tflag, sep);
@@ -435,14 +497,14 @@
if (!rflag && !intext) {
printf("\n--%s\n", sep);
- printf("Content-Type: text/plain; charset=UTF-8\n");
+ printf("Content-Type: text/plain; charset=US-ASCII; format=flowed\n");
printf("Content-Disposition: inline\n");
- printf("Content-Transfer-Encoding: quoted-printable\n\n");
+ printf("Content-Transfer-Encoding: 7bit\n\n");
intext = 1;
}
- gen_qp((uint8_t *)line, strlen(line), 78, 0);
+ gen_flowd((uint8_t *)line, strlen(line), 78, 0);
}
if (!rflag && !inheader)
printf("\n--%s--\n", sep);
printf 'Bcc: \n'