From e235e694cd6f73e7b8f73c4da7c5d2a8fbac4e84 Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Tue, 5 May 2020 14:05:57 -0400 Subject: Encode the path as Subject with Q --- notemap.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'notemap.c') diff --git a/notemap.c b/notemap.c index b448a2a..61112e5 100644 --- a/notemap.c +++ b/notemap.c @@ -153,15 +153,8 @@ static char *format(const char *from, const char *uuid, const char *path) { localtime(&status.st_mtime) ); - char subj[78 - (sizeof("Subject: ") - 1)] = {0}; - for (size_t i = 0; i < sizeof(subj) - 1; ++i) { - if (!path[i]) break; - subj[i] = (path[i] & 0x80 ? '?' : path[i]); - } - #define HEADERS \ "From: <%s>\r\n" \ - "Subject: %s\r\n" \ "Date: %s\r\n" \ "X-Universally-Unique-Identifier: %s\r\n" \ "X-Uniform-Type-Identifier: com.apple.mail-note\r\n" \ @@ -169,13 +162,15 @@ static char *format(const char *from, const char *uuid, const char *path) { "MIME-Version: 1.0\r\n" \ "Content-Type: text/plain; charset=\"utf-8\"\r\n" \ "Content-Transfer-Encoding: quoted-printable\r\n" \ - "\r\n" + "Subject: =?utf-8?Q?" +#define HEADERS_END "?=\r\n\r\n" size_t max = sizeof(HEADERS) + strlen(from) - + strlen(subj) + strlen(date) + strlen(uuid) + + 3 * strlen(path) + + sizeof(HEADERS_END) + 3 * status.st_size + 3 * status.st_size / 76; char *buf = malloc(max); @@ -183,8 +178,18 @@ static char *format(const char *from, const char *uuid, const char *path) { FILE *msg = fmemopen(buf, max, "w"); if (!msg) err(EX_OSERR, "fmemopen"); - fprintf(msg, HEADERS, from, subj, date, uuid); -#undef HEADERS + fprintf(msg, HEADERS, from, date, uuid); + + for (const char *ch = path; *ch; ++ch) { + if ((uint8_t)*ch & 0x80) { + fprintf(msg, "=%02hhX", (uint8_t)*ch); + } else if (*ch == ' ') { + fprintf(msg, "_"); + } else { + fprintf(msg, "%c", *ch); + } + } + fprintf(msg, HEADERS_END); int ch; int len = 0; -- cgit 1.4.1
path: root/Makefile (unfollow)
Commit message (Collapse)Author
2018-11-27Rename project catgirlJune McEnroe
This simplifies things.
2018-11-27Add M-m key to insert a blank lineJune McEnroe
For manually marking the log.
2018-10-28Add notification with notify-sendJune McEnroe
2018-10-28Use const char *argv[] signaturesJune McEnroe
C is really weird about this stuff, but this makes more sense to me.
2018-10-23Fix verbose view name in man pageJune McEnroe
2018-10-22Add more URL schemesJune McEnroe
2018-10-22Rework status lineJune McEnroe
2018-10-22Rename status and verbose tagsJune McEnroe
2018-09-16Revert "Race parallel connects"June McEnroe
This reverts commit e3e2b36ecf6a1340f1dc2542233bafe0862447fa. Apparently racing *all* of the connections is not something you should do, and I can't be bothered with all the extra logic to do this "correctly" according to RFC 8305. Provide an API, you cowards. What I did want to do was give IPv6 any chance at all of being used, but I'm just going to leave that up to the order getaddrinfo returns. It's someone else's fault.
2018-09-16Race parallel connectsJune McEnroe
2018-09-15Call tls_error when tls_connect_socket failsJune McEnroe
2018-09-15Try successive getaddrinfo resultsJune McEnroe
2018-09-15Render README from chatte.7June McEnroe
2018-09-14Factor out uiPrompt to call on nick changeJune McEnroe
2018-09-14Run test binaries with set -e and semicolonsJune McEnroe
BSD make behaves oddly when trying to replace with &.
2018-09-14Fail target when any test binary failsJune McEnroe
2018-09-14Run tests in default targetJune McEnroe
2018-09-14Add termEvent testsJune McEnroe
2018-09-14Check width of entire next word including codesJune McEnroe
This results in a tiny bit of premature wrapping for color codes, but that isn't a problem.
2018-09-14Remove word handling from formatParseJune McEnroe
2018-09-14Apply consecutive formatting codes at onceJune McEnroe
Fixes the failing splits test.
2018-09-14Add tests for formatParseJune McEnroe
With one currently failing so you know they're worth it.
2018-09-13Preview with nick in input windowJune McEnroe
2018-09-13Never send PRIVMSG to TagStatus or TagVerboseJune McEnroe
2018-09-13Move color selection to format.cJune McEnroe
2018-09-13Fix len for format->split at end of stringJune McEnroe
2018-09-13Avoid uninitialized x in uiReadJune McEnroe
2018-09-13Add IRCDefault to colors enumJune McEnroe
2018-09-13Return a format->split even at the end of the stringJune McEnroe
2018-09-13Fix weird tab-complete after commaJune McEnroe
I have no idea why I did this.
2018-09-13Rewrite UI againJune McEnroe
The persistent topic is gone and the status line is now at the top. The status formatting still needs to be reworked. I also want to try showing the nick in the input window so it really looks like your next message.
2018-09-12Add note about C-oJune McEnroe
Why are there so few well usable ctrl key bindings?
2018-09-12Use formatParse split to position input cursorJune McEnroe
2018-09-12Factor out IRC formatting parsingJune McEnroe
2018-09-11Add /help equivalent to /manJune McEnroe
2018-09-11Don't render every PM as a pingJune McEnroe
2018-09-11Add urlOpenMatchJune McEnroe
2018-09-10Depend on man.sh for chroot.tar targetJune McEnroe
2018-09-10Set LESSSECURE=1 in man.shJune McEnroe
Ridiculous.
2018-09-10Add /man commandJune McEnroe
2018-09-10Install man page in chrootJune McEnroe
2018-09-10Install man pageJune McEnroe
2018-09-10Split keys into subsections and document colorsJune McEnroe
2018-09-10Add "blank" lines to chatte.1June McEnroe
2018-09-10Document key bindings in chatte.1June McEnroe
2018-09-08Document slash commands in chatte.1June McEnroe