Commit a62b01ec authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

ftp: check if server supports UTF-8 (fixes #2746)

parent 283669aa
...@@ -342,6 +342,23 @@ static int Login( vlc_object_t *p_access, access_sys_t *p_sys ) ...@@ -342,6 +342,23 @@ static int Login( vlc_object_t *p_access, access_sys_t *p_sys )
return 0; return 0;
} }
static void FeaturesCheck( void *opaque, const char *feature )
{
bool *unicode = opaque;
if( strcasestr( feature, "UTF8" ) != NULL )
*unicode = true;
}
static const char *IsASCII( const char *str )
{
int8_t c;
for( const char *p = str; (c = *p) != '\0'; p++ )
if( c < 0 )
return NULL;
return str;
}
static int Connect( vlc_object_t *p_access, access_sys_t *p_sys ) static int Connect( vlc_object_t *p_access, access_sys_t *p_sys )
{ {
if( Login( p_access, p_sys ) < 0 ) if( Login( p_access, p_sys ) < 0 )
...@@ -351,17 +368,13 @@ static int Connect( vlc_object_t *p_access, access_sys_t *p_sys ) ...@@ -351,17 +368,13 @@ static int Connect( vlc_object_t *p_access, access_sys_t *p_sys )
if( ftp_SendCommand( p_access, p_sys, "EPSV ALL" ) < 0 ) if( ftp_SendCommand( p_access, p_sys, "EPSV ALL" ) < 0 )
{ {
msg_Err( p_access, "cannot request extended passive mode" ); msg_Err( p_access, "cannot request extended passive mode" );
net_Close( p_sys->fd_cmd ); goto error;
return -1;
} }
if( ftp_RecvCommand( p_access, p_sys, NULL, NULL ) == 2 ) if( ftp_RecvCommand( p_access, p_sys, NULL, NULL ) == 2 )
{ {
if( net_GetPeerAddress( p_sys->fd_cmd, p_sys->sz_epsv_ip, NULL ) ) if( net_GetPeerAddress( p_sys->fd_cmd, p_sys->sz_epsv_ip, NULL ) )
{ goto error;
net_Close( p_sys->fd_cmd );
return -1;
}
} }
else else
{ {
...@@ -374,10 +387,23 @@ static int Connect( vlc_object_t *p_access, access_sys_t *p_sys ) ...@@ -374,10 +387,23 @@ static int Connect( vlc_object_t *p_access, access_sys_t *p_sys )
net_Close( p_sys->fd_cmd ); net_Close( p_sys->fd_cmd );
if( Login( p_access, p_sys ) ) if( Login( p_access, p_sys ) )
{ goto error;
net_Close( p_sys->fd_cmd ); }
return -1;
} /* features check */
bool unicode = false;
if( ftp_SendCommand( p_access, p_sys, "FEAT" ) < 0
|| ftp_RecvAnswer( p_access, p_sys, NULL, NULL,
FeaturesCheck, &unicode ) < 0 )
{
msg_Err( p_access, "cannot get server features" );
goto error;
}
if( (unicode ? IsUTF8 : IsASCII)(p_sys->url.psz_path) == NULL )
{
msg_Err( p_access, "unsupported path: \"%s\"", p_sys->url.psz_path );
goto error;
} }
/* check binary mode support */ /* check binary mode support */
...@@ -385,11 +411,13 @@ static int Connect( vlc_object_t *p_access, access_sys_t *p_sys ) ...@@ -385,11 +411,13 @@ static int Connect( vlc_object_t *p_access, access_sys_t *p_sys )
ftp_RecvCommand( p_access, p_sys, NULL, NULL ) != 2 ) ftp_RecvCommand( p_access, p_sys, NULL, NULL ) != 2 )
{ {
msg_Err( p_access, "cannot set binary transfer mode" ); msg_Err( p_access, "cannot set binary transfer mode" );
net_Close( p_sys->fd_cmd ); goto error;
return -1;
} }
return 0; return 0;
error:
net_Close( p_sys->fd_cmd );
return -1;
} }
...@@ -429,8 +457,6 @@ static int parseURL( vlc_url_t *url, const char *path ) ...@@ -429,8 +457,6 @@ static int parseURL( vlc_url_t *url, const char *path )
return VLC_EGENERIC; /* ASCII and directory not supported */ return VLC_EGENERIC; /* ASCII and directory not supported */
} }
decode_URI( url->psz_path ); decode_URI( url->psz_path );
/* FIXME: check for UTF-8 support, otherwise only ASCII is allowed */
EnsureUTF8( url->psz_path );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment