From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms12 with LMTPS id +LC0Ad13SF9KcwAAsNZ9tg (envelope-from ) for ; Fri, 28 Aug 2020 03:19:57 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id aL1LOdx3SF/6fAAAB5/wlQ (envelope-from ) for ; Fri, 28 Aug 2020 03:19:56 +0000 Received: from pb-smtp20.pobox.com (pb-smtp20.pobox.com [173.228.157.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 8B72B9404C3 for ; Fri, 28 Aug 2020 03:19:56 +0000 (UTC) Received: from pb-smtp20.pobox.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id C826CF392C; Thu, 27 Aug 2020 23:19:54 -0400 (EDT) (envelope-from kyle@kyleam.com) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=sasl; bh=ZdSiTu8UX8FzwGulLmgKY3WJB mc=; b=uEr1OB+YZsJZ1tos+ERIV2EnAlG8O0aY9DmHHu6HOb9e7vSKXnnp9xoMj LmKbZ1ZMNI5HQKU6HMX7qrKtFbQvnoeLvqmRjqyWrnaPRq1DPkJ2QlP45y1x3AVm NCRflWefcq5Jolof9FkwqRubCAuRCPZG349Jsk1LFr7l26qbRY= Received: from pb-smtp20.sea.icgroup.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id C216AF392B; Thu, 27 Aug 2020 23:19:54 -0400 (EDT) (envelope-from kyle@kyleam.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=kyleam.com; h=from:to:subject:date:message-id:in-reply-to:references:mime-version:content-transfer-encoding; s=mesmtp; bh=VGuVz/Xq9OreZK1t43BAym0wvxL1ydFna5/37QDLAaM=; b=Q01Xz70ZC/ufZUsvjhVlo9LoOASQqsmEvRygUsI78MEgtIFJerpJMHDCaA0RwMRCQ35hmKrjeo/mw5/eEtj8r7srKeyVcoePycYXXDAcnGU3JkY5rAE/6sLkFcd9nxJuv6CL6KG50NiTsVfV37eTTo/1cx5j1utHgndvOz+ZFSA= Received: from localhost (unknown [45.33.91.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp20.pobox.com (Postfix) with ESMTPSA id 3633EF392A; Thu, 27 Aug 2020 23:19:52 -0400 (EDT) (envelope-from kyle@kyleam.com) From: Kyle Meyer To: piem@inbox.kyleam.com Subject: [PATCH 4/4] elfeed, eww: Be stricter about the returned message ID Date: Thu, 27 Aug 2020 23:19:20 -0400 Message-Id: <20200828031920.7515-5-kyle@kyleam.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200828031920.7515-1-kyle@kyleam.com> References: <20200828031920.7515-1-kyle@kyleam.com> MIME-Version: 1.0 X-Pobox-Relay-ID: 5659F700-E8DD-11EA-A6A4-F0EA2EB3C613-24757444!pb-smtp20.pobox.com Content-Transfer-Encoding: quoted-printable X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=pobox.com header.s=sasl header.b=uEr1OB+Y; dkim=fail (body hash did not verify) header.d=kyleam.com header.s=mesmtp header.b=Q01Xz70Z; dmarc=none; spf=pass (aspmx1.migadu.com: domain of kyle@kyleam.com designates 173.228.157.52 as permitted sender) smtp.mailfrom=kyle@kyleam.com X-Spam-Score: 2.50 X-TUID: z5vbA8Q9XL3L Using the second group in piem-link-re is not reliable because the trailing part of the URL may be anything. Instead get the inboxes :url first and then generate a regular expression that has that value as the prefix. --- piem-elfeed.el | 9 +++++---- piem-eww.el | 9 +++++---- piem.el | 26 ++++++++++++++------------ 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/piem-elfeed.el b/piem-elfeed.el index 5a6472b..b1e112b 100644 --- a/piem-elfeed.el +++ b/piem-elfeed.el @@ -43,10 +43,11 @@ (defun piem-elfeed-get-inbox () =20 (defun piem-elfeed-get-mid () "Return the message ID of an `elfeed-show-mode' buffer." - (when (derived-mode-p 'elfeed-show-mode) - (when-let ((link (elfeed-entry-link elfeed-show-entry))) - (and (string-match piem-link-re link) - (match-string 2 link))))) + (when-let ((inbox (piem-elfeed-get-inbox)) + (inbox-url (piem-inbox-get :url inbox)) + (link (elfeed-entry-link elfeed-show-entry))) + (and (string-match (piem-message-link-re inbox-url) link) + (match-string 1 link)))) =20 ;;;###autoload (define-minor-mode piem-elfeed-mode diff --git a/piem-eww.el b/piem-eww.el index 5fb629b..62b7166 100644 --- a/piem-eww.el +++ b/piem-eww.el @@ -42,10 +42,11 @@ (defun piem-eww-get-inbox () =20 (defun piem-eww-get-mid () "Return the message ID of an EWW buffer." - (when (derived-mode-p 'eww-mode) - (when-let ((link (plist-get eww-data :url))) - (and (string-match piem-link-re link) - (match-string 2 link))))) + (when-let ((inbox (piem-eww-get-inbox)) + (inbox-url (piem-inbox-get :url inbox)) + (url (plist-get eww-data :url))) + (and (string-match (piem-message-link-re inbox-url) url) + (match-string 1 url)))) =20 ;;;###autoload (define-minor-mode piem-eww-mode diff --git a/piem.el b/piem.el index 4b840cb..da1a693 100644 --- a/piem.el +++ b/piem.el @@ -255,18 +255,20 @@ (defun piem-process-call-with-buffer-input (defun piem--ensure-trailing-slash (s) (if (string-match-p ".+/\\'" s) s (concat s "/"))) =20 -(defvar piem-link-re - (rx "/" (group (one-or-more (not (any "/" "\n")))) - "/" (group (one-or-more (not (any "/" "\n")))) - "/" (group (zero-or-one - (or "raw" - "t.mbox.gz" - (and (or "t" "T") "/#" - (one-or-more (not (any "/" "\n"))))))) - string-end) - "Regular expression matching public-inbox HTTP link. -The first group is the inbox, the second is the message ID, and -the rest is any trailing endpoint.") +(defun piem-message-link-re (url &optional mid) + "Return a regular expression matching a public-inbox url. +URL should be the top-level url for the inbox. If MID is +non-nil, make the match specific for that message." + (rx-to-string + `(and ,(piem--ensure-trailing-slash url) + (group ,(or mid + '(one-or-more (not (any "/" "\n"))))) + "/" (group (zero-or-one + (or "raw" + "t.mbox.gz" + (and (or "t" "T") "/#" + (one-or-more (not (any "/" "\n"))))))) + string-end))) =20 (defun piem-inbox-by-header-match () "Return inbox based on matching message headers. --=20 2.28.0