cruxports/mblaze/mblaze-fofl.patch

106 lines
4.0 KiB
Diff
Raw Normal View History

2022-05-12 11:16:20 -04:00
--- mblaze-1.2/mmime.c 2021-12-12 11:39:30.000000000 -0500
+++ mblaze-1.2f/mmime.c 2022-05-12 09:13:44.371637134 -0400
@@ -143,6 +143,70 @@ gen_qp(uint8_t *s, off_t size, size_t ma
2022-02-05 15:39:19 -05:00
return linelen;
}
2022-05-12 11:16:20 -04:00
+
2022-02-05 15:39:19 -05:00
+size_t
+gen_flowd(uint8_t *s, off_t size, size_t maxlinelen, size_t linelen)
+{
2022-05-12 11:16:20 -04:00
+ 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;
2022-02-05 15:39:19 -05:00
+
2022-05-12 11:16:20 -04:00
+ if (linelen >= maxlinelen-mb-!!header) {
+ linelen = 0;
+ if (header) {
+ printf("\n");
+ } else {
+ puts(" ");
+ }
+ }
2022-02-05 15:39:19 -05:00
+
+
2022-05-12 11:16:20 -04:00
+ 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;
2022-02-05 15:39:19 -05:00
+}
+
static const char *
basenam(const char *s)
{
2022-05-12 11:16:20 -04:00
@@ -444,8 +508,8 @@ gen_build()
2022-02-05 15:39:19 -05:00
inheader = 0;
printf("MIME-Version: 1.0\n");
if (rflag) {
2022-05-12 11:16:20 -04:00
- printf("Content-Type:%s", contenttype ? contenttype : " text/plain; charset=UTF-8\n");
- printf("Content-Transfer-Encoding:%s", contenttransferenc ? contenttransferenc : " quoted-printable\n");
+ printf("Content-Type:%s", contenttype ? contenttype : " text/plain; charset=US-ASCII; format=flowed\n");
+ printf("Content-Transfer-Encoding:%s", contenttransferenc ? contenttransferenc : " 7bit\n");
printf("\n");
2022-02-05 15:39:19 -05:00
} else {
printf("Content-Type: %s; boundary=\"%s\"\n", tflag, sep);
2022-05-12 11:16:20 -04:00
@@ -487,9 +551,9 @@ gen_build()
2022-02-05 15:39:19 -05:00
if (!rflag && !intext) {
printf("\n--%s\n", sep);
2022-05-12 11:16:20 -04:00
- printf("Content-Type:%s", contenttype ? contenttype : " text/plain; charset=UTF-8\n");
+ printf("Content-Type:%s", contenttype ? contenttype : " text/plain; charset=US-ASCII; format=flowed\n");
2022-02-05 15:39:19 -05:00
printf("Content-Disposition: inline\n");
2022-05-12 11:16:20 -04:00
- printf("Content-Transfer-Encoding:%s", contenttransferenc ? contenttransferenc : " quoted-printable\n");
+ printf("Content-Transfer-Encoding:%s", contenttransferenc ? contenttransferenc : " 7bit\n");
printf("\n");
2022-02-05 15:39:19 -05:00
intext = 1;
2022-05-12 11:16:20 -04:00
@@ -498,7 +562,7 @@ gen_build()
if (contenttransferenc)
printf("%s", line);
else
- gen_qp((uint8_t *)line, strlen(line), 78, 0);
+ gen_flowd((uint8_t *)line, strlen(line), 78, 0);
2022-02-05 15:39:19 -05:00
2022-05-12 11:16:20 -04:00
emptybody = 0;
2022-02-05 15:39:19 -05:00
}