[ZendTo] Patch for better url construction
Santiago Garcia Mantinan
manty at manty.net
Thu Jul 15 13:27:55 BST 2021
Hi!
While trying to use ZendTo both with an internal and external (through
reverse proxy) urls I was strugling a bit, then I realised that if I
had serverRoot set to "" ZendTo would generate the url (maybe this can
be used for multidomain support?), so I only had to set it like that
and also set advertisedServerRoot to the right url (the external one
that is going to be on the mails and all that.
I got to some problems there, as the URL was not being correctly
generated, this patch fixes that, first taking into account the
forwarded server and using it instead of the server name, and then
fixing a bug that clears the url if it doesn't have a ? on it (at
least that is what is happening to me on Debian 10 with php 7.3.29.
As always, comments are welcome.
Regards.
--- 6.11/opt/zendto/lib/NSSDropbox.php 2021-06-18 16:27:01.000000000 +0200
+++ /opt/zendto/lib/NSSDropbox.php 2021-07-13 13:05:18.880981984 +0200
@@ -58,10 +58,10 @@
} else {
$port = ":$port";
}
- $NSSDROPBOX_URL = "http".($https ? "s" :
"")."://".@$_SERVER['SERVER_NAME'].$port.@$_SERVER['REQUEST_URI'];
+ $NSSDROPBOX_URL = "http".($https ? "s" : "")."://".(null !==
@$_SERVER['HTTP_X_FORWARDED_SERVER'] ?
@$_SERVER['HTTP_X_FORWARDED_SERVER'] :
@$_SERVER['SERVER_NAME']).$port.@$_SERVER['REQUEST_URI'];
// Delete anything after a ? (and the ? itself)
// $NSSDROPBOX_URL = preg_replace('/\?.*$/', '', $NSSDROPBOX_URL);
- $NSSDROPBOX_URL = substr($NSSDROPBOX_URL, 0, strpos($NSSDROPBOX_URL, '?'));
+ if (strpos($NSSDROPBOX_URL, '?')) {$NSSDROPBOX_URL =
substr($NSSDROPBOX_URL, 0, strpos($NSSDROPBOX_URL, '?'));}
// Should now end in blahblah.php or simply a directory /
// if ( !preg_match('/\/$/',$NSSDROPBOX_URL) ) {
if ( substr($NSSDROPBOX_URL, -1) !== '/' ) {
--
Manty/BestiaTester -> http://manty.net
More information about the ZendTo
mailing list