Changeset 16c7c7141889b674a61da67a83a470323ad6f660
- Timestamp:
- 27/09/05 18:18:11 (3 years ago)
- git-parent:
- Files:
-
- modules/access/gnomevfs.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
modules/access/gnomevfs.c
r95024e0 r16c7c71 34 34 35 35 #include "charset.h" 36 #include "network.h" 36 37 37 38 /***************************************************************************** … … 88 89 char *psz = NULL; 89 90 char *psz_uri = NULL; 91 char *psz_unescaped = NULL; 92 char *psz_expand_tilde = NULL; 90 93 GnomeVFSURI *p_uri = NULL; 91 94 GnomeVFSResult i_ret; … … 126 129 { 127 130 psz_name = malloc( strlen( p_access->psz_access ) + 128 strlen( p_access->psz_path ) + 3 ); 129 strcpy( psz_name, p_access->psz_access ); 130 strcat( psz_name, "://" ); 131 strcat( psz_name, p_access->psz_path ); 131 strlen( p_access->psz_path ) + 4 ); 132 sprintf( psz_name, "%s://%s", p_access->psz_access, 133 p_access->psz_path ); 132 134 } 133 135 else … … 135 137 psz_name = strdup( p_access->psz_path ); 136 138 } 137 138 139 psz = ToLocale( psz_name ); 139 140 /* Use gnome_vfs_make_uri_from_input_with_dirs for local paths, as it deals 141 relative directories, and gnome_vfs_make_uri_from_input_with_dirs 142 otherwise */ 143 psz_uri = gnome_vfs_make_uri_from_input_with_dirs( psz, 144 GNOME_VFS_MAKE_URI_DIR_CURRENT); 145 if( *psz_uri != '/' ) 146 { 147 g_free( psz_uri ); 148 psz_uri = gnome_vfs_escape_host_and_path_string( psz ); 149 } 150 140 psz_expand_tilde = gnome_vfs_expand_initial_tilde( psz ); 141 LocaleFree( psz ); 142 143 psz_unescaped = gnome_vfs_make_uri_from_shell_arg( psz_expand_tilde ); 144 145 /* gnome_vfs_make_uri_from_shell_arg will only escape the uri 146 for relative paths. So we need to use 147 gnome_vfs_escape_host_and_path_string in other cases. */ 148 149 if( !strcmp( psz_unescaped, psz_expand_tilde ) ) 150 { 151 /* Now we are sure that we have a complete valid unescaped URI beginning 152 with the protocol. We want to escape it. However, gnomevfs's escaping 153 function are broken and will try to escape characters un the username/ 154 password field. So parse the URI with vlc_UrlParse ans only escape the 155 path */ 156 157 vlc_url_t url; 158 char *psz_escaped_path; 159 char *psz_path_begin; 160 161 vlc_UrlParse( &url, psz_unescaped, 0 ); 162 163 psz_escaped_path = gnome_vfs_escape_path_string( url.psz_path ); 164 165 /* Now let's reconstruct a valid URI from all that stuff */ 166 psz_path_begin = strstr( psz_unescaped, url.psz_path ); 167 *psz_path_begin = '\0'; 168 psz_uri = malloc( strlen( psz_unescaped ) + 169 strlen( psz_escaped_path ) + 1 ); 170 sprintf( psz_uri, "%s%s",psz_unescaped, psz_escaped_path ); 171 172 g_free( psz_escaped_path ); 173 g_free( psz_unescaped ); 174 } 175 else 176 { 177 psz_uri = psz_unescaped; 178 } 179 180 g_free( psz_expand_tilde ); 151 181 p_uri = gnome_vfs_uri_new( psz_uri ); 152 182 if( p_uri ) … … 158 188 if( i_ret ) 159 189 { 160 msg_Err( p_access, "cannot get file info (%s)",161 gnome_vfs_result_to_string( i_ret ) );190 msg_Err( p_access, "cannot get file info for uri %s (%s)", 191 psz_uri, gnome_vfs_result_to_string( i_ret ) ); 162 192 gnome_vfs_file_info_unref( p_sys->p_file_info ); 163 193 gnome_vfs_uri_unref( p_uri); 164 194 free( p_sys ); 165 free( psz_uri );195 g_free( psz_uri ); 166 196 free( psz_name ); 167 197 return VLC_EGENERIC; … … 171 201 { 172 202 msg_Warn( p_access, "cannot parse MRL %s or unsupported protocol", psz_name ); 173 LocaleFree( psz );174 203 g_free( psz_uri ); 175 204 free( p_sys ); … … 177 206 return VLC_EGENERIC; 178 207 } 179 LocaleFree( psz );180 208 181 209 msg_Dbg( p_access, "opening file `%s'", psz_uri ); … … 186 214 gnome_vfs_result_to_string( i_ret ) ); 187 215 188 LocaleFree( psz);216 gnome_vfs_uri_unref( p_uri); 189 217 g_free( psz_uri ); 190 gnome_vfs_uri_unref( p_uri);191 218 free( p_sys ); 192 free( psz_uri );193 219 free( psz_name ); 194 220 return VLC_EGENERIC; … … 223 249 msg_Err( p_access, "file %s is empty, aborting", psz_name ); 224 250 gnome_vfs_file_info_unref( p_sys->p_file_info ); 251 gnome_vfs_uri_unref( p_uri); 225 252 free( p_sys ); 226 free( psz_uri );253 g_free( psz_uri ); 227 254 free( psz_name ); 228 255 return VLC_EGENERIC;
