Dear Prosody Developers,

I suggest this tiny patch for inclusion into the
mod_http_upload_external

Motivation:
`share.php` belives PHP_SELF to be the full URI given to the uploaded
file. However, for example, using nginx, with certain configurations
this is not the case, as can be seen, say, here:
https://code.r3pek.org/r3pek/docker-prosody-http-upload-external/src/branch/master/default.conf

The user has to modify share.php, and provide a separate UPLOAD_FILENAME
header.

This tweak could be avoided using DOCUMENT_URI.
I checked with nginx, and OpenBSD's https, and it seems to work without
problems.

The patch is attached to this mesage:

-- 
You received this message because you are subscribed to the Google Groups 
"prosody-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to prosody-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prosody-dev/87r1dnu9n8.fsf%40laptop.lockywolf.net.
# HG changeset patch
# User Vladimir Nikishkin <lockyw...@gmail.com>
# Date 1631851521 -28800
#      Fri Sep 17 12:05:21 2021 +0800
# Node ID 458f54a8d27f7e09ea05e671b172009a35aacc02
# Parent  59f53cf665735fa3ea457c20b4e1f4cc8941a1fa
mod_http_upload_external: replace PHP_SELF with DOCUMENT_URI as more compatible.

Using PHP_SELF to determine file name is not entirely compatible with nginx,
and since there is a more compatible alternative, I suggest using it.

diff -r 59f53cf66573 -r 458f54a8d27f mod_http_upload_external/share.php
--- a/mod_http_upload_external/share.php	Thu Sep 16 22:57:52 2021 +0200
+++ b/mod_http_upload_external/share.php	Fri Sep 17 12:05:21 2021 +0800
@@ -64,7 +64,7 @@
 
 /* Do not edit below this line unless you know what you are doing (spoiler: nobody does) */
 
-$upload_file_name = substr($_SERVER['PHP_SELF'], strlen($_SERVER['SCRIPT_NAME'])+1);
+$upload_file_name = substr($_SERVER['DOCUMENT_URI'], strlen($_SERVER['SCRIPT_NAME'])+1);
 $store_file_name = $CONFIG_STORE_DIR . '/store-' . hash('sha256', $upload_file_name);
 
 $request_method = $_SERVER['REQUEST_METHOD'];
Thank you for your consideration.

-- 
Your sincerely,
Vladimir Nikishkin (MiEr, lockywolf)
(Laptop)

-- 
You received this message because you are subscribed to the Google Groups 
"prosody-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to prosody-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prosody-dev/87r1dnu9n8.fsf%40laptop.lockywolf.net.

Reply via email to