mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-12-05 18:59:51 +00:00
Fix: return a JSON 404 for unmatched API URLs and non-numeric document ids (#14917)
This commit is contained in:
1 parent
fca95bc821
commit
d1251aaef6
4 files changed
+123
No files matched your search
@@ -1036,6 +1036,14 @@ class DocumentViewSet(
|
||||
# Bound the IN clauses used for search results and through-table lookups.
|
||||
selection_data_batch_size = 10_000
|
||||
|
||||
def initial(self, request, *args, **kwargs):
|
||||
super().initial(request, *args, **kwargs)
|
||||
# Only ASCII digits can be a document id, reject anything else here, before
|
||||
# any action calls int() on it
|
||||
pk = kwargs.get("pk")
|
||||
if pk is not None and not (pk.isascii() and pk.isdigit()):
|
||||
raise Http404
|
||||
|
||||
def _get_selection_data_for_queryset(
|
||||
self,
|
||||
queryset: QuerySet[Document],
|
||||
|
||||
Reference in new issue
Block a user