From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms12 with LMTPS id HRieNTyNZV/4BAAAsNZ9tg (envelope-from ) for ; Sat, 19 Sep 2020 04:46:52 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id 4L+nMDyNZV8NYwAAbx9fmQ (envelope-from ) for ; Sat, 19 Sep 2020 04:46:52 +0000 Received: from pb-smtp1.pobox.com (pb-smtp1.pobox.com [64.147.108.70]) (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 86306940309 for ; Sat, 19 Sep 2020 04:46:49 +0000 (UTC) Received: from pb-smtp1.pobox.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 68D836C881; Sat, 19 Sep 2020 00:46:48 -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=zLG3f4QcWFJW6N8D6XEiQ/gZP nM=; b=x/hDQ31+94PfrpLiWRq7slmZRgYyoa8LWr1rXcAsnaZ+sf59lDNdSyHk1 /890W8CRIoC+/itg6q3NsrUOEKa/rxuJtYRyOxUOE/DOa1RZXqBe6e/NzUagNmoP yai40xKQ/ZNQR5+8yjzHGld+4oC3gtALRvJoMPj3mRo5g+4M2o= Received: from pb-smtp1.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 61F096C880; Sat, 19 Sep 2020 00:46:48 -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=PtXlqHDLXIcquYK1qYeslq8X+fihXYM1RkSzuMZ2g6Q=; b=yyld/JVDoejvMT9ZUglQlO2rxg8xUgWUxGIXNOX6HYNp/ZLzzTKLgUKCgIr7TT1jbuSLc+VqJDERciPkL7FXcHxwaLuIHwbE49/fpTgPhd/AvYnPWL/lWp30rluRSJOwgxu4Ka3vvz9vNd1XD7BxK9DLias5kOCg5g/x6TYotTc= 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-smtp1.pobox.com (Postfix) with ESMTPSA id D712F6C87E; Sat, 19 Sep 2020 00:46:47 -0400 (EDT) (envelope-from kyle@kyleam.com) From: Kyle Meyer To: piem@inbox.kyleam.com Subject: [PATCH 1/2] Escape message IDs when constructing URLs Date: Sat, 19 Sep 2020 00:46:38 -0400 Message-Id: <20200919044639.26871-2-kyle@kyleam.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200919044639.26871-1-kyle@kyleam.com> References: <20200919044639.26871-1-kyle@kyleam.com> MIME-Version: 1.0 X-Pobox-Relay-ID: 2036EAB8-FA33-11EA-96B6-01D9BED8090B-24757444!pb-smtp1.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=x/hDQ31+; dkim=fail (body hash did not verify) header.d=kyleam.com header.s=mesmtp header.b=yyld/JVD; dmarc=none; spf=pass (aspmx1.migadu.com: domain of kyle@kyleam.com designates 64.147.108.70 as permitted sender) smtp.mailfrom=kyle@kyleam.com X-Spam-Score: 2.50 X-TUID: wBgtSdx+loU/ Message IDs can include characters that must escaped before being included in the path part of public-inbox URLs. Add a variant of url-hexify-string that uses the same set of characters as public-inbox's mid_escape(). --- piem-b4.el | 2 +- piem.el | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/piem-b4.el b/piem-b4.el index b77d111..596e563 100644 --- a/piem-b4.el +++ b/piem-b4.el @@ -66,7 +66,7 @@ (defun piem-b4--get-am-files (mid coderepo args) (mid (piem-mid)) (buffer (condition-case nil (piem-download-and-decompress - (concat url mid "/t.mbox.gz")) + (concat url (piem-escape-mid mid) "/t.mbox= .gz")) (error nil)))) (with-current-buffer buffer (write-region nil nil mbox-thread)) diff --git a/piem.el b/piem.el index dd2b30e..7c6ca6f 100644 --- a/piem.el +++ b/piem.el @@ -261,7 +261,7 @@ (defun piem-message-link-re (url &optional mid) non-nil, make the match specific for that message." (rx-to-string `(and ,(piem--ensure-trailing-slash url) - (group ,(or mid + (group ,(or (and mid (piem-escape-mid mid)) '(one-or-more (not (any "/" "\n"))))) "/" (group (zero-or-one (or "raw" @@ -403,6 +403,16 @@ (defun piem-am-ready-mbox () =0C ;;;; Download helpers =20 +(defconst piem--unreserved-chars + (append url-unreserved-chars + ;; These extra characters follow what's used by + ;; public-inbox's mid_escape(). + (list ?! ?$ ?& ?' ?\( ?\) ?* ?+ ?, ?=3D ?: ?\; ?@))) + +(defun piem-escape-mid (mid) + "Escape MID for use in path part of a public-inbox URL." + (url-hexify-string mid piem--unreserved-chars)) + (defvar piem--has-gunzip) (defun piem-check-gunzip () "Return non-nil if gunzip is available." @@ -500,7 +510,7 @@ (defun piem-inject-thread-into-maildir (mid &optional= message-only) (when-let ((url (concat (or (piem-inbox-get :url) (user-error "Could not find inbox URL for current buf= fer")) - mid + (piem-escape-mid mid) (if message-only "/raw" "/t.mbox.gz"))) (buffer (url-retrieve-synchronously url 'silent))) (unwind-protect --=20 2.28.0