Skip to content

Commit

Permalink
also detect 'fetch()' requests as ajax
Browse files Browse the repository at this point in the history
  • Loading branch information
dill0wn authored and Carlos Cruz committed Jan 3, 2025
1 parent 06b7b89 commit 44106de
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Allura/allura/lib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,12 @@ def unique_attachments(attachments):
def is_ajax(request):
if request.headers.get('X-Requested-With', None) == 'XMLHttpRequest':
return True
# fetch - see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Sec-Fetch-Mode
if (
request.headers.get('Sec-Fetch-Mode', None) in ('cors', 'no-cors', 'same-origin')
and request.headers.get('Sec-Fetch-Dest', None) == 'empty'
):
return True
return False


Expand Down

0 comments on commit 44106de

Please sign in to comment.