From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <9front-bounces@9front.inri.net> X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI autolearn=ham autolearn_force=no version=3.4.4 Received: from 9front.inri.net (9front.inri.net [168.235.81.73]) by inbox.vuxu.org (Postfix) with ESMTP id CBF02220D9 for ; Fri, 17 May 2024 10:25:04 +0200 (CEST) Received: from pb-smtp2.pobox.com ([64.147.108.71]) by 9front; Fri May 17 04:23:40 -0400 2024 Received: from pb-smtp2.pobox.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 87F412607A for <9front@9front.org>; Fri, 17 May 2024 04:23:37 -0400 (EDT) (envelope-from me+unobe@fallglow.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=pobox.com; h=message-id :date:from:to:subject:in-reply-to:mime-version:content-type :content-transfer-encoding; s=sasl; bh=QgFEBnoNWClH8QVZhlQkX6fU/ nXP4w5pTPuDUEmoOoY=; b=g+WadqgWznjUR5nNDHzr5KnixCrwkc23WME8181wl aUxFg7mNBnh8GRbJjijL96jXG/EmNqYwhXUauDPXqVwmtKJFh91HqrY+L39Cl/+p bHQUSx2TxDAjQfiKEq58DFnWGRQR++AyiWeMaNIL1q45AeHluEUOyEV2BM7e2ewI pg= Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 7FA9F26079 for <9front@9front.org>; Fri, 17 May 2024 04:23:37 -0400 (EDT) (envelope-from me+unobe@fallglow.com) Received: from strider.localdomain (unknown [47.37.156.153]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pb-smtp2.pobox.com (Postfix) with ESMTPSA id C880B26078 for <9front@9front.org>; Fri, 17 May 2024 04:23:36 -0400 (EDT) (envelope-from me+unobe@fallglow.com) Message-ID: Date: Fri, 17 May 2024 01:23:35 -0700 From: Romano To: 9front@9front.org In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Pobox-Relay-ID: C2149EC8-1426-11EF-92D1-25B3960A682E-09620299!pb-smtp2.pobox.com List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: injection replication realtime-java reduce/map template Subject: Re: [9front] [PATCH] upas: allow send to parse e-mail descriptions like marshal Reply-To: 9front@9front.org Precedence: bulk Crap, after taking some more time to test, I realized that both patches were copying more than need be at times, and the second patch actually truncated the address too much most of the time. I RTFM for strncpy because I didn't get why the last patch I sent was so faulty. I thought it might have been char-by-char copying backwards or something in the implementation. Alas, no, it was me not understanding what was happening with re: to the index where I was setting the null byte. This is the last patch I'll send re: this until I get some feedback or until June. And my apologies for anyone who read the previous iterations already. From: Romano Date: Fri, 17 May 2024 08:08:34 +0000 Subject: [PATCH] upas/send: parse e-mail descriptions like marshal /sys/src/cmd/upas/marshal/marshal.c:/^printfrom parses an e-mail with a description (e.g., "A Name ") and sets the from to just the e-mail address portion. This does the same for upas/send so that upasname='A name ' can be used to both set the From: in marshal with a description and to match the correct from in upas/send for sending via smtp. --- diff e51d4aa069548de51d0e88a6d621d278e9138cd0 863b4ae53732ddeaf96dc23b0e9924651f2b4090 --- a/sys/src/cmd/upas/send/message.c +++ b/sys/src/cmd/upas/send/message.c @@ -1,6 +1,7 @@ #include "common.h" #include "send.h" #include +#include #include "../smtp/smtp.h" #include "../smtp/rfc822.tab.h" @@ -18,6 +19,23 @@ static String* getstring(Node *p); static String* getaddr(Node *p); +char * +userfrom(char *cp) +{ + char *s; + int n; + + if((n = strlen(cp)) > 4 && cp[n-1] == '>'){ + if((s = strrchr(cp, '<')) != nil && s != cp && isspace(s[-1])) { + s++; + cp[n-1] = '\0'; + strcpy(cp, s); + } + } + + return cp; +} + int default_from(message *mp) { @@ -32,7 +50,7 @@ return -1; } if(cp && *cp) - s_append(mp->sender, cp); + s_append(mp->sender, userfrom(cp)); else s_append(mp->sender, lp); free(cp);