@@ -62,8 +62,8 @@ static int proxy_request_fixup(request_rec *r,
6262 r -> handler = "proxy-server" ;
6363
6464 /* Rewrite the Destination header if present (for COPY/MOVE requests).
65- The Destination header contains a full URL pointing to the slave,
66- which needs to be rewritten to point to the master. */
65+ The Destination header contains a full URL pointing to the slave,
66+ which needs to be rewritten to point to the master. */
6767 {
6868 const char * destination = apr_table_get (r -> headers_in , "Destination" );
6969 if (destination ) {
@@ -75,28 +75,37 @@ static int proxy_request_fixup(request_rec *r,
7575 apr_uri_parse (r -> pool , master_uri , & master_uri_parsed ) == APR_SUCCESS &&
7676 dest_uri .path ) {
7777 const char * dest_path = svn_urlpath__canonicalize (dest_uri .path ,
78- r -> pool );
78+ r -> pool );
79+ /* URL-encode root_dir for comparison since dest_path is
80+ already encoded (from the Destination header). */
81+ const char * root_dir_encoded = svn_path_uri_encode (root_dir ,
82+ r -> pool );
7983 /* Check if destination path starts with root_dir */
80- if (strncmp (dest_path , root_dir , strlen (root_dir )) == 0 ) {
81- const char * remainder = dest_path + strlen (root_dir );
84+ if (strncmp (dest_path , root_dir_encoded ,
85+ strlen (root_dir_encoded )) == 0 ) {
86+ const char * remainder = dest_path + strlen (root_dir_encoded );
8287 const char * master_path = svn_urlpath__canonicalize (
8388 master_uri_parsed .path ,
8489 r -> pool );
90+ /* URL-encode master_path, then concatenate with remainder
91+ which is already encoded. */
92+ const char * master_path_encoded = svn_path_uri_encode (
93+ master_path , r -> pool );
8594 const char * new_path = apr_pstrcat (r -> pool ,
86- master_path ,
87- remainder ,
88- SVN_VA_NULL );
89- /* Reconstruct the destination URL with master's
90- host and rewritten path */
95+ master_path_encoded ,
96+ remainder ,
97+ SVN_VA_NULL );
98+ /* Reconstruct the destination URL with master's host and
99+ rewritten path. Do NOT re-encode new_path since the
100+ remainder portion is already URL-encoded. */
91101 dest_uri .hostname = master_uri_parsed .hostname ;
92102 dest_uri .scheme = master_uri_parsed .scheme ;
93103 dest_uri .port = master_uri_parsed .port ;
94104 dest_uri .port_str = master_uri_parsed .port_str ;
95- dest_uri .path = (char * )svn_path_uri_encode (new_path ,
96- r -> pool );
105+ dest_uri .path = (char * )new_path ;
97106
98107 apr_table_set (r -> headers_in , "Destination" ,
99- apr_uri_unparse (r -> pool , & dest_uri , 0 ));
108+ apr_uri_unparse (r -> pool , & dest_uri , 0 ));
100109 }
101110 }
102111 }
0 commit comments