guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Mummi wishlist: API using Message-ID


From: Kyle Meyer
Subject: Re: Mummi wishlist: API using Message-ID
Date: Fri, 18 Sep 2020 12:46:51 -0400

Kyle Meyer writes:

> For public-inbox URLs, there is one character that needs to be escaped:
> "/" with "%2F" (see <https://yhetil.org/guix-devel/_/text/help/>).

Correcting myself: I shouldn't take that help page as a complete
description of what needs to be escaped for public-inbox URLs.  It'd be
better to look at what public-inbox's code does itself, particularly
when it generates the path component of the URL for its Archived-At
header.  It feeds the message ID through this function:

,----[ lib/PublicInbox/MID.pm ]
| # RFC3986, section 3.3:
| sub MID_ESC () { '^A-Za-z0-9\-\._~!\$\&\';\(\)\*\+,;=:@' }
| sub mid_escape ($) { uri_escape_utf8($_[0], MID_ESC) }
`----

That code came with 9d1e5fad (www: do not unecessarily escape some chars
in paths, 2016-08-14).

So, if you want to perform the same escaping for your custom Elisp
function that generates public-inbox URLs, you can do something like
this:

    (let ((unreserved-chars
           (append url-unreserved-chars
                   '(?! ?$ ?& ?' ?\( ?\) ?* ?+ ?, ?= ?: ?@ ?\;))))
      (url-hexify-string "88@e.com" unreserved-chars)  ; => "88@e.com"
      (url-hexify-string "8%@e.com" unreserved-chars)  ; => "8%25@e.com"
      (url-hexify-string "8/@e.com" unreserved-chars)) ; => "8%2F@e.com"

Or, if you don't mind the unnecessary escaping (particularly of "@"),
you can just use url-hexify-string with the default set of unreserved
characters.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]