ftplistparser.c: fix handling of file LISTings using Windows EOL
Previously file.txt[CR][LF] would have been returned as file.tx (without the last t) if filetype is symlink. Now the t is included and the internal item_length includes the zero byte. Spotted using test 576 on Windows.
This commit is contained in:
@@ -728,7 +728,6 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb,
|
|||||||
case PL_UNIX_FILENAME_NAME:
|
case PL_UNIX_FILENAME_NAME:
|
||||||
parser->item_length++;
|
parser->item_length++;
|
||||||
if(c == '\r') {
|
if(c == '\r') {
|
||||||
parser->item_length--;
|
|
||||||
parser->state.UNIX.sub.filename = PL_UNIX_FILENAME_WINDOWSEOL;
|
parser->state.UNIX.sub.filename = PL_UNIX_FILENAME_WINDOWSEOL;
|
||||||
}
|
}
|
||||||
else if(c == '\n') {
|
else if(c == '\n') {
|
||||||
@@ -744,7 +743,7 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb,
|
|||||||
break;
|
break;
|
||||||
case PL_UNIX_FILENAME_WINDOWSEOL:
|
case PL_UNIX_FILENAME_WINDOWSEOL:
|
||||||
if(c == '\n') {
|
if(c == '\n') {
|
||||||
finfo->b_data[parser->item_offset + parser->item_length] = 0;
|
finfo->b_data[parser->item_offset + parser->item_length - 1] = 0;
|
||||||
parser->offsets.filename = parser->item_offset;
|
parser->offsets.filename = parser->item_offset;
|
||||||
parser->state.UNIX.main = PL_UNIX_FILETYPE;
|
parser->state.UNIX.main = PL_UNIX_FILETYPE;
|
||||||
result = ftp_pl_insert_finfo(conn, finfo);
|
result = ftp_pl_insert_finfo(conn, finfo);
|
||||||
@@ -837,7 +836,6 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb,
|
|||||||
case PL_UNIX_SYMLINK_TARGET:
|
case PL_UNIX_SYMLINK_TARGET:
|
||||||
parser->item_length++;
|
parser->item_length++;
|
||||||
if(c == '\r') {
|
if(c == '\r') {
|
||||||
parser->item_length --;
|
|
||||||
parser->state.UNIX.sub.symlink = PL_UNIX_SYMLINK_WINDOWSEOL;
|
parser->state.UNIX.sub.symlink = PL_UNIX_SYMLINK_WINDOWSEOL;
|
||||||
}
|
}
|
||||||
else if(c == '\n') {
|
else if(c == '\n') {
|
||||||
|
|||||||
Reference in New Issue
Block a user