summaryrefslogtreecommitdiff
path: root/patchwork/urls.py
diff options
context:
space:
mode:
authorDaniel Axtens <dja@axtens.net>2019-09-13 00:47:03 +1000
committerDaniel Axtens <dja@axtens.net>2019-09-25 07:40:19 +1000
commit5d7d5336dfeada28b036a5a3ba34d16ec8d83612 (patch)
treeb921ab9cbc060c42ad62e7a1536c573f800d3ea7 /patchwork/urls.py
parentab35df8c33a178b3b2349c1e4727393b94f5e916 (diff)
downloadpatchwork-5d7d5336dfeada28b036a5a3ba34d16ec8d83612.tar
patchwork-5d7d5336dfeada28b036a5a3ba34d16ec8d83612.tar.gz
Move to msgid based URLs
Migrate our URL schema as follows: Patches: /project/<linkname>/patch/<msgid>/ Cover Letters: /project/<linkname>/cover/<msgid>/ The usual sub-resources (mbox, raw) hang off those URLs. The old style URLs (/patch/NNN/*, /cover/NNN/*) redirect appropriately. I haven't attempted to do anything meaningful with series, and I have dropped any attempt to provide a generic message-id lookup or search functionality. One step at a time. Our database still stores message ids as with angle brackets; we just work around that rather than trying to migrate. That too can come later if we think the pain is justified. Partially-closes: #106 Reported-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org> Reported-by-but-I-don't-want-to-spam: Linus Torvalds <torvalds@linux-foundation.org> Reported-by: Stephen Finucane <stephen@that.guru> Signed-off-by: Daniel Axtens <dja@axtens.net>
Diffstat (limited to 'patchwork/urls.py')
-rw-r--r--patchwork/urls.py43
1 files changed, 33 insertions, 10 deletions
diff --git a/patchwork/urls.py b/patchwork/urls.py
index c24bf55..dcdcfb4 100644
--- a/patchwork/urls.py
+++ b/patchwork/urls.py
@@ -38,18 +38,41 @@ urlpatterns = [
name='project-detail'),
# patch views
- url(r'^patch/(?P<patch_id>\d+)/$', patch_views.patch_detail,
- name='patch-detail'),
- url(r'^patch/(?P<patch_id>\d+)/raw/$', patch_views.patch_raw,
- name='patch-raw'),
- url(r'^patch/(?P<patch_id>\d+)/mbox/$', patch_views.patch_mbox,
- name='patch-mbox'),
+ # NOTE(dja): Per the RFC, msgids can contain slashes. There doesn't seem
+ # to be an easy way to tell Django to urlencode the slash when generating
+ # URLs, so instead we must use a permissive regex (.+ rather than [^/]+).
+ # This also means we need to put the raw and mbox URLs first, otherwise the
+ # patch-detail regex will just greedily grab those parts into a massive and
+ # wrong msgid.
+ #
+ # This does mean that message-ids that end in '/raw/' or '/mbox/' will not
+ # work, but it is RECOMMENDED by the RFC that the right hand side of the @
+ # contains a domain, so I think breaking on messages that have "domains"
+ # ending in /raw/ or /mbox/ is good enough.
+ url(r'^project/(?P<project_id>[^/]+)/patch/(?P<msgid>.+)/raw/$',
+ patch_views.patch_raw, name='patch-raw'),
+ url(r'^project/(?P<project_id>[^/]+)/patch/(?P<msgid>.+)/mbox/$',
+ patch_views.patch_mbox, name='patch-mbox'),
+ url(r'^project/(?P<project_id>[^/]+)/patch/(?P<msgid>.+)/$',
+ patch_views.patch_detail, name='patch-detail'),
+ # ... old-style /patch/N/* urls
+ url(r'^patch/(?P<patch_id>\d+)/raw/$', patch_views.patch_raw_by_id,
+ name='patch-raw-redirect'),
+ url(r'^patch/(?P<patch_id>\d+)/mbox/$', patch_views.patch_mbox_by_id,
+ name='patch-mbox-redirect'),
+ url(r'^patch/(?P<patch_id>\d+)/$', patch_views.patch_by_id,
+ name='patch-id-redirect'),
# cover views
- url(r'^cover/(?P<cover_id>\d+)/$', cover_views.cover_detail,
- name='cover-detail'),
- url(r'^cover/(?P<cover_id>\d+)/mbox/$', cover_views.cover_mbox,
- name='cover-mbox'),
+ url(r'^project/(?P<project_id>[^/]+)/cover/(?P<msgid>.+)/mbox/$',
+ cover_views.cover_mbox, name='cover-mbox'),
+ url(r'^project/(?P<project_id>[^/]+)/cover/(?P<msgid>.+)/$',
+ cover_views.cover_detail, name='cover-detail'),
+ # ... old-style /cover/N/* urls
+ url(r'^cover/(?P<cover_id>\d+)/mbox/$', cover_views.cover_mbox_by_id,
+ name='cover-mbox-redirect'),
+ url(r'^cover/(?P<cover_id>\d+)/$', cover_views.cover_by_id,
+ name='cover-id-redirect'),
# comment views
url(r'^comment/(?P<comment_id>\d+)/$', comment_views.comment,