Accept a Message-ID contained in < > characters master github/master
authorJelte Fennema-Nio <github-tech@jeltef.nl>
Tue, 24 Sep 2024 20:55:49 +0000 (22:55 +0200)
committerMagnus Hagander <magnus@hagander.net>
Tue, 24 Sep 2024 20:55:49 +0000 (22:55 +0200)
At least GMail will show the Message-ID including the < > characters.

django/archives/mailarchives/views.py

index bf3336ed4ccf0d8f1cba2f7fc290469368c7512e..69172bd28f77add98ef10616cccd7c1ae75c3094 100644 (file)
@@ -769,11 +769,12 @@ def search(request):
     # Ok, we have all we need to do the search
 
     if query.find('@') > 0:
+        cleaned_id = query.strip().removeprefix('<').removesuffix('>')
         # This could be a messageid. So try to get that one specifically first.
         # We don't do a more specific check if it's a messageid because doing
         # a key lookup is cheap...
         curs.execute("SELECT messageid FROM messages WHERE messageid=%(q)s", {
-            'q': query,
+            'q': cleaned_id,
         })
         a = curs.fetchall()
         if len(a) == 1: