# [1] https://datatracker.ietf.org/doc/html/rfc3986.html#section-2
return self.url_msgid.replace('/', '%2F')
+ @staticmethod
+ def decode_msgid(msgid):
+ """Decode an encoded msgid.
+
+ Reverses :mod:`~url_msgid` and :mod:`~encoded_msgid` operations.
+ """
+ return f"<{msgid.replace('%2F', '/')}>"
+
def save(self, *args, **kwargs):
# Modifying a submission via admin interface changes '\n' newlines in
# message content to '\r\n'. We need to fix them to avoid problems,
def patch_detail(request, project_id, msgid):
project = get_object_or_404(Project, linkname=project_id)
- db_msgid = f"<{msgid.replace('%2F', '/')}>"
+ db_msgid = Patch.decode_msgid(msgid)
# redirect to cover letters where necessary
try:
def patch_raw(request, project_id, msgid):
- db_msgid = '<%s>' % msgid
+ db_msgid = Patch.decode_msgid(msgid)
project = get_object_or_404(Project, linkname=project_id)
patch = get_object_or_404(Patch, project_id=project.id, msgid=db_msgid)
def patch_mbox(request, project_id, msgid):
- db_msgid = '<%s>' % msgid
+ db_msgid = Patch.decode_msgid(msgid)
project = get_object_or_404(Project, linkname=project_id)
patch = get_object_or_404(Patch, project_id=project.id, msgid=db_msgid)
series_id = request.GET.get('series')