From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Matt Armstrong Newsgroups: gmane.emacs.bugs Subject: bug#58472: [PATCH] Make `message-unique-id' less prone to collisions Date: Sun, 16 Oct 2022 08:19:57 -0700 Message-ID: <871qr794o2.fsf@rfc20.org> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32904"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 58472@debbugs.gnu.org To: Paul Eggert , Stefan Kangas Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Oct 16 17:22:28 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ok5T9-0008Ln-UF for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 16 Oct 2022 17:22:28 +0200 Original-Received: from localhost ([::1]:53804 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ok5T8-0004fi-Nc for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 16 Oct 2022 11:22:26 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33108) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ok5Rn-0004ZY-Ey for bug-gnu-emacs@gnu.org; Sun, 16 Oct 2022 11:21:21 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:46818) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ok5Rm-0000oS-9M for bug-gnu-emacs@gnu.org; Sun, 16 Oct 2022 11:21:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ok5Rm-0005Fq-2M for bug-gnu-emacs@gnu.org; Sun, 16 Oct 2022 11:21:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Matt Armstrong Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 16 Oct 2022 15:21:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58472 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 58472-submit@debbugs.gnu.org id=B58472.166593361220100 (code B ref 58472); Sun, 16 Oct 2022 15:21:02 +0000 Original-Received: (at 58472) by debbugs.gnu.org; 16 Oct 2022 15:20:12 +0000 Original-Received: from localhost ([127.0.0.1]:45896 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ok5Qx-0005E6-L0 for submit@debbugs.gnu.org; Sun, 16 Oct 2022 11:20:11 -0400 Original-Received: from relay5-d.mail.gandi.net ([217.70.183.197]:54463) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ok5Qv-0005Dl-7b for 58472@debbugs.gnu.org; Sun, 16 Oct 2022 11:20:10 -0400 Original-Received: (Authenticated sender: matt@rfc20.org) by mail.gandi.net (Postfix) with ESMTPSA id 2F94B1C0003; Sun, 16 Oct 2022 15:20:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rfc20.org; s=gm1; t=1665933602; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=6WR3ygEX1ZvfLtRmDoN6a3NH7TNOp8zxriyfQYSb4C0=; b=TRTBV9QnOaGxQlG6AHmA37DzKqQrZZDBg2f1xgt11dYNDrhhWYyhebznLgxN5Q0/gPhpOv aWadeLjxPKFqTRB5MzrCIVDfFB38MsOsuR0PpjfoPz3qq2jS2tDKRKS4MzKGdFezvb2rkH 7nTtvJ1P4Q/pMdNyjm3aAy+eoyUP8r9MRnGpRwl6xYfgUZXAZBu3Au/LhsLx1DVg9+OFwJ ghNMCSJarrdnKKiw+vwAQutZme74zfim8QJxfnchPHl8ZLwbimnr+3Gap+Zs7NeIj5vfco qzDCercICpvCIZ9OZPFCtqbKrGQa3whE3w6RlIts/wwzhKlfaApGKbsoj39cYw== Original-Received: from matt by naz with local (Exim 4.96) (envelope-from ) id 1ok5Qk-001LK9-0V; Sun, 16 Oct 2022 08:19:58 -0700 In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:245658 Archived-At: Paul Eggert writes: > On 2022-10-12 19:46, Stefan Kangas wrote: > >> The main goal is to avoid collisions, but using the time also gives an >> idea of when the message was sent, which is kind of nice. > > That info is in the Date: line, along with zillions of other Received: > lines. There should be no need to repeat it in the Message-ID line. > >> Time also >> guarantees a somewhat unique value even if the user has happened to set >> the random seed. > > If that's a concern, we should be using more-random data, e.g., with > > (base64-encode-string > (secure-hash 'md5 'iv-auto 128 nil t)) > > if we want 128 bits of randomness (this yields a string like > "B8a3usyu5QSE/rTLu0nIHg=="). Small suggestion: `base64-url-encode-string` avoids any trailing `===` and uses slightly preferable non-alnum chars (I think). But both can generate Message-Id with "command line switch" chars: either ?- or ?/. Since some tools expect users to work directly with Message-ID at times (https://notmuchmail.org/) it might be nice to avoid leading non-alnum chars, and possibly avoid '-' to avoid any confusion with a UUID (in the sense of the schema defined by the RFC standard). Maybe a base 62 encoder could be written just for this, as Emacs' version of this doesn't need to be fast. Can a string be turned into a non-negative bignum integer in (simple) elisp? -- matt (sent from an Emacs running the feature/noverlay branch)