From 55aefbeccecef94972376fca44e1ff00f8b22973 Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Sat, 30 Jun 2012 16:03:25 +1200 Subject: [PATCH] Try to trace how we get caldav.php/ doubled in a path. --- htdocs/always.php | 10 ++++++---- inc/always.php.in | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/htdocs/always.php b/htdocs/always.php index 1ef6d6b6..c99d36d9 100644 --- a/htdocs/always.php +++ b/htdocs/always.php @@ -301,9 +301,6 @@ function getStatusMessage($status) { function ConstructURL( $partial_path, $force_script = false ) { global $c; - $partial_path = rawurlencode($partial_path); - $partial_path = str_replace( '%2F', '/', $partial_path); - if ( ! isset($c->_url_script_path) ) { $c->protocol_server_port_script = str_replace( 'index.php', 'caldav.php', $c->protocol_server_port_script); $c->_url_script_path = (preg_match('#/$#', $c->protocol_server_port_script) ? 'caldav.php' : ''); @@ -314,10 +311,15 @@ function ConstructURL( $partial_path, $force_script = false ) { if ( $force_script ) { if ( ! preg_match( '#/caldav\.php$#', $url ) ) $url .= '/caldav.php'; } - $url .= $partial_path; + $url .= str_replace( '%2F', '/', rawurlencode($partial_path)); $url = preg_replace( '#^(https?://.+)//#', '$1/', $url ); // Ensure we don't double any '/' $url = preg_replace('#^https?://[^/]+#', '', $url ); // Remove any protocol + hostname portion + if ( strstr($url, 'caldav.php/caldav.php') ) { + trace_bug('Duplicated caldav.php/ in URL "%s" from partial_path=%s, force_script=%s', $url, $partial_path, ($force_script?'true':'false')); + $url = str_replace( 'caldav.php/caldav.php', 'caldav.php', $url ); // Ensure we don't double any 'caldav.php/' + } + return $url; } diff --git a/inc/always.php.in b/inc/always.php.in index 6b455ac6..adf2ac1e 100644 --- a/inc/always.php.in +++ b/inc/always.php.in @@ -301,9 +301,6 @@ function getStatusMessage($status) { function ConstructURL( $partial_path, $force_script = false ) { global $c; - $partial_path = rawurlencode($partial_path); - $partial_path = str_replace( '%2F', '/', $partial_path); - if ( ! isset($c->_url_script_path) ) { $c->protocol_server_port_script = str_replace( 'index.php', 'caldav.php', $c->protocol_server_port_script); $c->_url_script_path = (preg_match('#/$#', $c->protocol_server_port_script) ? 'caldav.php' : ''); @@ -314,10 +311,15 @@ function ConstructURL( $partial_path, $force_script = false ) { if ( $force_script ) { if ( ! preg_match( '#/caldav\.php$#', $url ) ) $url .= '/caldav.php'; } - $url .= $partial_path; + $url .= str_replace( '%2F', '/', rawurlencode($partial_path)); $url = preg_replace( '#^(https?://.+)//#', '$1/', $url ); // Ensure we don't double any '/' $url = preg_replace('#^https?://[^/]+#', '', $url ); // Remove any protocol + hostname portion + if ( strstr($url, 'caldav.php/caldav.php') ) { + trace_bug('Duplicated caldav.php/ in URL "%s" from partial_path=%s, force_script=%s', $url, $partial_path, ($force_script?'true':'false')); + $url = str_replace( 'caldav.php/caldav.php', 'caldav.php', $url ); // Ensure we don't double any 'caldav.php/' + } + return $url; }