1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

ftp: ftp didn't handle filenames with spaces.

This commit is contained in:
Witold Filipczyk 2007-01-27 10:05:40 +01:00 committed by Witold Filipczyk
parent 8678908412
commit 047bf7e1c6
2 changed files with 25 additions and 9 deletions

View File

@ -63,12 +63,8 @@ init_directory_listing(struct string *page, struct uri *uri)
&& !add_char_to_string(&dirpath, local ? CHAR_DIR_SEP : '/'))
goto out_of_memory;
if (local || uri->protocol == PROTOCOL_FSP || uri->protocol == PROTOCOL_GOPHER
|| uri->protocol == PROTOCOL_SMB) {
/* A little hack to get readable Gopher names. We should find a
* way to do it more general. */
decode_uri_string(&dirpath);
}
/* Decode uri for displaying. */
decode_uri_string(&dirpath);
if (!local && !add_char_to_string(&location, '/'))
goto out_of_memory;

View File

@ -683,8 +683,15 @@ add_file_cmd_to_str(struct connection *conn)
if (!conn->uri->datalen
|| conn->uri->data[conn->uri->datalen - 1] == '/') {
struct string uri_string;
/* Commands to get directory listing. */
if (!init_string(&uri_string)) {
done_string(&command);
done_string(&ftp_data_command);
abort_connection(conn, S_OUT_OF_MEM);
return NULL;
}
ftp->dir = 1;
ftp->pending_commands = 4;
@ -695,17 +702,27 @@ add_file_cmd_to_str(struct connection *conn)
add_string_to_string(&command, &ftp_data_command);
add_to_string(&command, "CWD ");
add_uri_to_string(&command, conn->uri, URI_PATH);
add_uri_to_string(&uri_string, conn->uri, URI_PATH);
decode_uri_string(&uri_string);
add_string_to_string(&command, &uri_string);
add_crlf_to_string(&command);
add_to_string(&command, "LIST");
add_crlf_to_string(&command);
done_string(&uri_string);
conn->from = 0;
} else {
struct string uri_string;
/* Commands to get a file. */
if (!init_string(&uri_string)) {
done_string(&command);
done_string(&ftp_data_command);
abort_connection(conn, S_OUT_OF_MEM);
return NULL;
}
ftp->dir = 0;
ftp->pending_commands = 3;
@ -727,8 +744,11 @@ add_file_cmd_to_str(struct connection *conn)
}
add_to_string(&command, "RETR ");
add_uri_to_string(&command, conn->uri, URI_PATH);
add_uri_to_string(&uri_string, conn->uri, URI_PATH);
decode_uri_string(&uri_string);
add_string_to_string(&command, &uri_string);
add_crlf_to_string(&command);
done_string(&uri_string);
}
done_string(&ftp_data_command);
@ -1134,7 +1154,7 @@ display_dir_entry(struct cache_entry *cached, off_t *pos, int *tries,
}
add_to_string(&string, "<a href=\"");
add_html_to_string(&string, ftp_info->name.source, ftp_info->name.length);
encode_uri_string(&string, ftp_info->name.source, ftp_info->name.length, 0);
if (ftp_info->type == FTP_FILE_DIRECTORY)
add_char_to_string(&string, '/');
add_to_string(&string, "\">");