diff options
| author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-30 19:39:58 +0000 |
|---|---|---|
| committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-30 19:39:58 +0000 |
| commit | 75862df735995fa131a66eb3484f59251dd25f35 (patch) | |
| tree | d52c86e37238912df5449434fcf0cb5ddef111ba /net/third_party | |
| parent | dd11b93793657dbc2ed74481873df2eb91fe059a (diff) | |
| download | chromium_src-75862df735995fa131a66eb3484f59251dd25f35.zip chromium_src-75862df735995fa131a66eb3484f59251dd25f35.tar.gz chromium_src-75862df735995fa131a66eb3484f59251dd25f35.tar.bz2 | |
Sync ParseFTPList with Mozilla upstream.
Also fix chromium.patch so that it's possible to apply it.
It turns out my editor removed whitespace from ParseFTPList.cpp anyway,
and somehow the patch itself was corrupted.
The plan is to remove this code after our own LIST parsing code is ready,
but for now we still need it.
TEST=none
BUG=none
Review URL: http://codereview.chromium.org/450008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33312 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/third_party')
| -rw-r--r-- | net/third_party/parseftp/ParseFTPList.cpp | 259 | ||||
| -rw-r--r-- | net/third_party/parseftp/chromium.patch | 111 |
2 files changed, 193 insertions, 177 deletions
diff --git a/net/third_party/parseftp/ParseFTPList.cpp b/net/third_party/parseftp/ParseFTPList.cpp index 002e705..014f661 100644 --- a/net/third_party/parseftp/ParseFTPList.cpp +++ b/net/third_party/parseftp/ParseFTPList.cpp @@ -40,6 +40,7 @@ #include <ctype.h> +#include "base/logging.h" #include "base/string_util.h" using base::Time; @@ -48,6 +49,13 @@ using base::Time; namespace net { +static inline int ParsingFailed(struct list_state *state) +{ + if (state->parsed_one || state->lstyle) /* junk if we fail to parse */ + return '?'; /* this time but had previously parsed successfully */ + return '"'; /* its part of a comment or error message */ +} + int ParseFTPList(const char *line, struct list_state *state, struct list_result *result ) { @@ -75,7 +83,7 @@ int ParseFTPList(const char *line, struct list_state *state, /* strip leading whitespace */ while (*line == ' ' || *line == '\t') line++; - + /* line is terminated at first '\0' or '\n' */ p = line; while (*p && *p != '\n') @@ -109,25 +117,25 @@ int ParseFTPList(const char *line, struct list_state *state, pos = 0; while (pos < linelen && numtoks < (sizeof(tokens)/sizeof(tokens[0])) ) { - while (pos < linelen && + while (pos < linelen && (line[pos] == ' ' || line[pos] == '\t' || line[pos] == '\r')) pos++; if (pos < linelen) { tokens[numtoks] = &line[pos]; - while (pos < linelen && + while (pos < linelen && (line[pos] != ' ' && line[pos] != '\t' && line[pos] != '\r')) pos++; if (tokens[numtoks] != &line[pos]) { toklen[numtoks] = (&line[pos] - tokens[numtoks]); - numtoks++; + numtoks++; } } - } + } if (!numtoks) - return (state->parsed_one || state->lstyle) ? '?' : '"'; + return ParsingFailed(state); linelen_sans_wsp = &(tokens[numtoks-1][toklen[numtoks-1]]) - tokens[0]; if (numtoks == (sizeof(tokens)/sizeof(tokens[0])) ) @@ -150,7 +158,7 @@ int ParseFTPList(const char *line, struct list_state *state, while (pos < (linelen-1)) { p = &line[pos++]; - if (*p == '/') + if (*p == '/') result->fe_type = 'd'; /* its a dir */ else if (*p == 'r') result->fe_type = 'f'; /* its a file */ @@ -224,9 +232,9 @@ int ParseFTPList(const char *line, struct list_state *state, { /* try VMS Multinet/UCX/CMS server */ /* * Legal characters in a VMS file/dir spec are [A-Z0-9$.-_~]. - * '$' cannot begin a filename and `-' cannot be used as the first - * or last character. '.' is only valid as a directory separator - * and <file>.<type> separator. A canonical filename spec might look + * '$' cannot begin a filename and `-' cannot be used as the first + * or last character. '.' is only valid as a directory separator + * and <file>.<type> separator. A canonical filename spec might look * like this: DISK$VOL:[DIR1.DIR2.DIR3]FILE.TYPE;123 * All VMS FTP servers LIST in uppercase. * @@ -237,9 +245,9 @@ int ParseFTPList(const char *line, struct list_state *state, (numtoks == 1 || (numtoks == 2 && toklen[0] == 9 && memcmp(tokens[0], "Directory", 9)==0 ))) { - /* If no dirstyle has been detected yet, and this line is a + /* If no dirstyle has been detected yet, and this line is a * VMS list's dirname, then turn on VMS dirstyle. - * eg "ACA:[ANONYMOUS]", "DISK$FTP:[ANONYMOUS]", "SYS$ANONFTP:" + * eg "ACA:[ANONYMOUS]", "DISK$FTP:[ANONYMOUS]", "SYS$ANONFTP:" */ p = tokens[0]; pos = toklen[0]; @@ -260,7 +268,7 @@ int ParseFTPList(const char *line, struct list_state *state, (p[pos] == '-' && (p[pos+1] == ']' || p[pos+1] == '.'))) break; } - else if (p[pos] != '.' && p[pos] != '~' && + else if (p[pos] != '.' && p[pos] != '~' && !isdigit(p[pos]) && !isalpha(p[pos])) break; else if (isalpha(p[pos]) && p[pos] != toupper(p[pos])) @@ -285,12 +293,12 @@ int ParseFTPList(const char *line, struct list_state *state, break; } if (pos == 0) - { + { state->lstyle = 'V'; return '?'; /* its junk */ } } - /* fallthrough */ + /* fallthrough */ } else if ((tokens[0][toklen[0]-1]) != ';') { @@ -309,7 +317,7 @@ int ParseFTPList(const char *line, struct list_state *state, toklen[5] < 4 || *tokens[5] != '(' || /* perms */ (tokens[5][toklen[5]-1]) != ')' )) ; - else if ( (toklen[2] == 10 || toklen[2] == 11) && + else if ( (toklen[2] == 10 || toklen[2] == 11) && (tokens[2][toklen[2]-5]) == '-' && (tokens[2][toklen[2]-9]) == '-' && (((toklen[3]==4 || toklen[3]==5 || toklen[3]==7 || toklen[3]==8) && @@ -326,14 +334,14 @@ int ParseFTPList(const char *line, struct list_state *state, } if (lstyle == 'V') { - /* + /* * MultiNet FTP: * LOGIN.COM;2 1 4-NOV-1994 04:09 [ANONYMOUS] (RWE,RWE,,) * PUB.DIR;1 1 27-JAN-1994 14:46 [ANONYMOUS] (RWE,RWE,RE,RWE) * README.FTP;1 %RMS-E-PRV, insufficient privilege or file protection violation * ROUSSOS.DIR;1 1 27-JAN-1994 14:48 [CS,ROUSSOS] (RWE,RWE,RE,R) * S67-50903.JPG;1 328 22-SEP-1998 16:19 [ANONYMOUS] (RWED,RWED,,) - * UCX FTP: + * UCX FTP: * CII-MANUAL.TEX;1 213/216 29-JAN-1996 03:33:12 [ANONYMOU,ANONYMOUS] (RWED,RWED,,) * CMU/VMS-IP FTP * [VMSSERV.FILES]ALARM.DIR;1 1/3 5-MAR-1993 18:09 @@ -348,7 +356,7 @@ int ParseFTPList(const char *line, struct list_state *state, pos = 0; if (*p == '[' && toklen[0] >= 4) /* CMU style */ { - if (p[1] != ']') + if (p[1] != ']') { p++; pos++; @@ -356,7 +364,7 @@ int ParseFTPList(const char *line, struct list_state *state, while (lstyle && pos < toklen[0] && *p != ']') { if (*p != '$' && *p != '.' && *p != '_' && *p != '-' && - *p != '~' && !isdigit(*p) && !isalpha(*p)) + *p != '~' && !isdigit(*p) && !isalpha(*p)) lstyle = 0; pos++; p++; @@ -364,6 +372,7 @@ int ParseFTPList(const char *line, struct list_state *state, if (lstyle && pos < (toklen[0]-1)) { /* ']' was found and there is at least one character after it */ + DCHECK(*p == ']') << "unexpected state"; pos++; p++; tokmarker = pos; /* length of leading "[DIR1.DIR2.etc]" */ @@ -401,8 +410,8 @@ int ParseFTPList(const char *line, struct list_state *state, lstyle = 0; } else if (numtoks == 1) - { - /* if VMS has been detected and there is only one token and that + { + /* if VMS has been detected and there is only one token and that * token was a VMS filename then this is a multiline VMS LIST entry. */ if (pos >= (sizeof(state->carry_buf)-1)) @@ -429,7 +438,7 @@ int ParseFTPList(const char *line, struct list_state *state, } } } /* passed initial tests */ - } /* else if ((tokens[0][toklen[0]-1]) != ';') */ + } /* else if ((tokens[0][toklen[0]-1]) != ';') */ if (lstyle == 'V') { @@ -454,7 +463,7 @@ int ParseFTPList(const char *line, struct list_state *state, pos = 0; while (pos < toklen[0] && (tokens[0][pos]) != ';') pos++; - + result->fe_cinfs = 1; result->fe_type = 'f'; result->fe_fname = tokens[0]; @@ -480,16 +489,16 @@ int ParseFTPList(const char *line, struct list_state *state, pos = 0; while (pos < toklen[1] && (tokens[1][pos]) != '/') pos++; - + /* - * I've never seen size come back in bytes, its always in blocks, and + * I've never seen size come back in bytes, its always in blocks, and * the following test fails. So, always perform the "size in blocks". * I'm leaving the "size in bytes" code if'd out in case we ever need * to re-instate it. */ #if 0 if (pos < toklen[1] && ( (pos<<1) > (toklen[1]-1) || - (strtoul(tokens[1], (char **)0, 10) > + (strtoul(tokens[1], (char **)0, 10) > strtoul(tokens[1]+pos+1, (char **)0, 10)) )) { /* size is in bytes */ if (pos > (sizeof(result->fe_size)-1)) @@ -500,11 +509,11 @@ int ParseFTPList(const char *line, struct list_state *state, else /* size is in blocks */ #endif { - /* size requires multiplication by blocksize. + /* size requires multiplication by blocksize. * * We could assume blocksize is 512 (like Lynx does) and - * shift by 9, but that might not be right. Even if it - * were, doing that wouldn't reflect what the file's + * shift by 9, but that might not be right. Even if it + * were, doing that wouldn't reflect what the file's * real size was. The sanest thing to do is not use the * LISTing's filesize, so we won't (like ftpmirror). * @@ -520,7 +529,7 @@ int ParseFTPList(const char *line, struct list_state *state, long long size = strtoul(tokens[1], NULL, 10) * 512; base::snprintf(result->fe_size, sizeof(result->fe_size), "%lld", size); - } + } } /* if (result->fe_type != 'd') */ @@ -533,8 +542,8 @@ int ParseFTPList(const char *line, struct list_state *state, month_num = 0; for (pos = 0; pos < (12*3); pos+=3) { - if (tbuf[0] == month_names[pos+0] && - tbuf[1] == month_names[pos+1] && + if (tbuf[0] == month_names[pos+0] && + tbuf[1] == month_names[pos+1] && tbuf[2] == month_names[pos+2]) break; month_num++; @@ -552,7 +561,7 @@ int ParseFTPList(const char *line, struct list_state *state, result->fe_time.second = atoi(p+3); result->fe_time.hour = atoi(tokens[3]); result->fe_time.minute = atoi(p); - + return result->fe_type; } /* if (isdigit(*tokens[1])) */ @@ -604,8 +613,8 @@ int ParseFTPList(const char *line, struct list_state *state, { p = tokens[pos+4]; if ((toklen[pos+4] == 10 && p[4] == '-' && p[7] == '-') || - (toklen[pos+4] >= 7 && toklen[pos+4] <= 9 && - p[((p[1]!='/')?(2):(1))] == '/' && + (toklen[pos+4] >= 7 && toklen[pos+4] <= 9 && + p[((p[1]!='/')?(2):(1))] == '/' && p[((p[1]!='/')?(5):(4))] == '/')) /* Y2K bugs possible ("7/06/102" or "13/02/101") */ { @@ -626,13 +635,13 @@ int ParseFTPList(const char *line, struct list_state *state, } /* if (numtoks >= 7) */ /* extra checking if first pass */ - if (lstyle && !state->lstyle) + if (lstyle && !state->lstyle) { for (pos = 0, p = tokens[0]; lstyle && pos < toklen[0]; pos++, p++) - { + { if (isalpha(*p) && toupper(*p) != *p) lstyle = 0; - } + } for (pos = tokmarker+1; pos <= tokmarker+3; pos++) { if (!(toklen[pos] == 1 && *tokens[pos] == '-')) @@ -644,14 +653,14 @@ int ParseFTPList(const char *line, struct list_state *state, } } } - for (pos = 0, p = tokens[tokmarker+4]; + for (pos = 0, p = tokens[tokmarker+4]; lstyle && pos < toklen[tokmarker+4]; pos++, p++) { if (*p == '/') - { + { /* There may be Y2K bugs in the date. Don't simplify to * pos != (len-3) && pos != (len-6) like time is done. - */ + */ if ((tokens[tokmarker+4][1]) == '/') { if (pos != 1 && pos != 4) @@ -665,7 +674,7 @@ int ParseFTPList(const char *line, struct list_state *state, else if (*p == '-' && pos != 4 && pos != 7) lstyle = 0; } - for (pos = 0, p = tokens[tokmarker+5]; + for (pos = 0, p = tokens[tokmarker+5]; lstyle && pos < toklen[tokmarker+5]; pos++, p++) { if (*p != ':' && !isdigit(*p)) @@ -726,13 +735,13 @@ int ParseFTPList(const char *line, struct list_state *state, result->fe_fnlen += 1 + toklen[1]; } - /* oldstyle LISTING: - * files/dirs not on the 'A' minidisk are not RETRievable/CHDIRable + /* oldstyle LISTING: + * files/dirs not on the 'A' minidisk are not RETRievable/CHDIRable if (toklen[tokmarker+4] != 10 && *tokens[tokmarker-1] != 'A') return '?'; */ - - /* VM/CMS LISTings have no usable filesize field. + + /* VM/CMS LISTings have no usable filesize field. * Have to use the 'SIZE' command for that. */ return result->fe_type; @@ -754,22 +763,22 @@ int ParseFTPList(const char *line, struct list_state *state, * "07-21-00 01:19PM 52275 Name Plate.jpg" * "07-14-00 01:38PM 2250540 Valentineoffprank-HiRes.jpg" */ - if ((numtoks >= 4) && toklen[0] == 8 && toklen[1] == 7 && + if ((numtoks >= 4) && toklen[0] == 8 && toklen[1] == 7 && (*tokens[2] == '<' || isdigit(*tokens[2])) ) { p = tokens[0]; - if ( isdigit(p[0]) && isdigit(p[1]) && p[2]=='-' && + if ( isdigit(p[0]) && isdigit(p[1]) && p[2]=='-' && isdigit(p[3]) && isdigit(p[4]) && p[5]=='-' && isdigit(p[6]) && isdigit(p[7]) ) { p = tokens[1]; - if ( isdigit(p[0]) && isdigit(p[1]) && p[2]==':' && - isdigit(p[3]) && isdigit(p[4]) && + if ( isdigit(p[0]) && isdigit(p[1]) && p[2]==':' && + isdigit(p[3]) && isdigit(p[4]) && (p[5]=='A' || p[5]=='P') && p[6]=='M') { lstyle = 'W'; if (!state->lstyle) - { + { p = tokens[2]; /* <DIR> or <JUNCTION> */ if (*p != '<' || p[toklen[2]-1] != '>') @@ -835,7 +844,7 @@ int ParseFTPList(const char *line, struct list_state *state, result->fe_type = 'l'; result->fe_fnlen = p - result->fe_fname; result->fe_lname = p + 4; - result->fe_lnlen = &(line[linelen]) + result->fe_lnlen = &(line[linelen]) - result->fe_lname; break; } @@ -872,7 +881,7 @@ int ParseFTPList(const char *line, struct list_state *state, return '?'; */ - return result->fe_type; + return result->fe_type; } /* if (lstyle == 'W' && (!state->lstyle || state->lstyle == lstyle)) */ } /* if (!lstyle && (!state->lstyle || state->lstyle == 'W')) */ #endif @@ -883,9 +892,9 @@ int ParseFTPList(const char *line, struct list_state *state, if (!lstyle && (!state->lstyle || state->lstyle == 'O')) /* OS/2 test */ { /* 220 server IBM TCP/IP for OS/2 - FTP Server ver 23:04:36 on Jan 15 1997 ready. - * fixed position, space padded columns. I have only a vague idea + * fixed position, space padded columns. I have only a vague idea * of what the contents between col 18 and 34 might be: All I can infer - * is that there may be attribute flags in there and there may be + * is that there may be attribute flags in there and there may be * a " DIR" in there. * * 1 2 3 4 5 6 @@ -919,7 +928,7 @@ int ParseFTPList(const char *line, struct list_state *state, { lstyle = 'O'; /* OS/2 */ if (!state->lstyle) - { + { for (pos = 1; lstyle && pos < toklen[0]; pos++) { if (!isdigit(tokens[0][pos])) @@ -944,14 +953,14 @@ int ParseFTPList(const char *line, struct list_state *state, /* I don't have a real listing to determine exact pos, so scan. */ for (pos = (18-18); pos < ((35-18)-4); pos++) { - if (p[pos+0] == ' ' && p[pos+1] == 'D' && + if (p[pos+0] == ' ' && p[pos+1] == 'D' && p[pos+2] == 'I' && p[pos+3] == 'R') { result->fe_type = 'd'; break; } } - + if (result->fe_type != 'd') { pos = toklen[0]; @@ -959,8 +968,8 @@ int ParseFTPList(const char *line, struct list_state *state, pos = (sizeof(result->fe_size)-1); memcpy( result->fe_size, tokens[0], pos ); result->fe_size[pos] = '\0'; - } - + } + result->fe_time.month = atoi(&p[35-18]) - 1; result->fe_time.day_of_month = atoi(&p[38-18]); result->fe_time.year = atoi(&p[41-18]); @@ -968,7 +977,7 @@ int ParseFTPList(const char *line, struct list_state *state, result->fe_time.year += 100; result->fe_time.hour = atoi(&p[46-18]); result->fe_time.minute = atoi(&p[49-18]); - + /* the caller should do this (if dropping "." and ".." is desired) if (result->fe_type == 'd' && result->fe_fname[0] == '.' && (result->fe_fnlen == 1 || (result->fe_fnlen == 2 && @@ -983,7 +992,7 @@ int ParseFTPList(const char *line, struct list_state *state, #endif /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ - + #if defined(SUPPORT_LSL) if (!lstyle && (!state->lstyle || state->lstyle == 'U')) /* /bin/ls & co. */ { @@ -1011,9 +1020,9 @@ int ParseFTPList(const char *line, struct list_state *state, * uid/gid instead of username/groupname: * "drwxr-xr-x 2 0 0 512 May 28 22:17 etc" */ - + bool is_old_Hellsoft = false; - + if (numtoks >= 6) { /* there are two perm formats (Hellsoft/NetWare and *IX strmode(3)). @@ -1030,7 +1039,7 @@ int ParseFTPList(const char *line, struct list_state *state, p = tokens[1]; pos = toklen[1]; } - if ((pos == 9 || pos == 10) && + if ((pos == 9 || pos == 10) && (*p == '[' && p[pos-1] == ']') && (p[1] == 'R' || p[1] == '-') && (p[2] == 'W' || p[2] == '-') && @@ -1044,7 +1053,7 @@ int ParseFTPList(const char *line, struct list_state *state, } } } - else if ((toklen[0] == 10 || toklen[0] == 11) + else if ((toklen[0] == 10 || toklen[0] == 11) && strchr("-bcdlpsw?DFam", *tokens[0])) { p = &(tokens[0][1]); @@ -1075,9 +1084,9 @@ int ParseFTPList(const char *line, struct list_state *state, isalpha(tokens[pos+1][1]) && isalpha(tokens[pos+1][2]) /* (\d|\d\d) */ && isdigit(*tokens[pos+2]) && - (toklen[pos+2] == 1 || + (toklen[pos+2] == 1 || (toklen[pos+2] == 2 && isdigit(tokens[pos+2][1]))) - && toklen[pos+3] >= 4 && isdigit(*tokens[pos+3]) + && toklen[pos+3] >= 4 && isdigit(*tokens[pos+3]) /* (\d\:\d\d\:\d\d|\d\d\:\d\d\:\d\d) */ && (toklen[pos+3] <= 5 || ( (toklen[pos+3] == 7 || toklen[pos+3] == 8) && @@ -1090,13 +1099,13 @@ int ParseFTPList(const char *line, struct list_state *state, isdigit(tokens[pos+3][1]) && isdigit(tokens[pos+3][2]) ) /* (\d\:\d\d|\d\:\d\d\:\d\d) */ - || ((toklen[pos+3] == 4 || toklen[pos+3] == 7) && + || ((toklen[pos+3] == 4 || toklen[pos+3] == 7) && (tokens[pos+3][1]) == ':' && isdigit(tokens[pos+3][2]) && isdigit(tokens[pos+3][3])) /* (\d\d\:\d\d|\d\d\:\d\d\:\d\d) */ - || ((toklen[pos+3] == 5 || toklen[pos+3] == 8) && + || ((toklen[pos+3] == 5 || toklen[pos+3] == 8) && isdigit(tokens[pos+3][1]) && (tokens[pos+3][2]) == ':' && - isdigit(tokens[pos+3][3]) && isdigit(tokens[pos+3][4])) + isdigit(tokens[pos+3][3]) && isdigit(tokens[pos+3][4])) ) ) { @@ -1120,8 +1129,8 @@ int ParseFTPList(const char *line, struct list_state *state, p = tokens[tokmarker+1]; for (i = 0; i < (12*3); i+=3) { - if (p[0] == month_names[i+0] && - p[1] == month_names[i+1] && + if (p[0] == month_names[i+0] && + p[1] == month_names[i+1] && p[2] == month_names[i+2]) break; month_num++; @@ -1137,7 +1146,7 @@ int ParseFTPList(const char *line, struct list_state *state, { state->parsed_one = 1; state->lstyle = lstyle; - + result->fe_cinfs = 0; result->fe_type = '?'; if (*tokens[0] == 'd' || *tokens[0] == 'l') @@ -1175,7 +1184,7 @@ int ParseFTPList(const char *line, struct list_state *state, result->fe_time.minute = atoi(p+3); if (p[5] == ':') result->fe_time.second = atoi(p+6); - + if (!state->now_tm_valid) { Time t = Time::Now(); @@ -1188,9 +1197,9 @@ int ParseFTPList(const char *line, struct list_state *state, if ( (( state->now_tm.month << 5) + state->now_tm.day_of_month) < ((result->fe_time.month << 5) + result->fe_time.day_of_month) ) result->fe_time.year--; - + } /* time/year */ - + // there is exacly 1 space between filename and previous token in all // outputs except old Hellsoft if (!is_old_Hellsoft) @@ -1242,18 +1251,18 @@ int ParseFTPList(const char *line, struct list_state *state, { p = result->fe_fname[result->fe_fnlen-1]; pos = result->fe_type; - if (pos == 'd') { + if (pos == 'd') { if (*p == '/') result->fe_fnlen--; /* directory */ - } else if (pos == 'l') { + } else if (pos == 'l') { if (*p == '@') result->fe_fnlen--; /* symlink */ - } else if (pos == 'f') { + } else if (pos == 'f') { if (*p == '*') result->fe_fnlen--; /* executable */ } else if (*p == '=' || *p == '%' || *p == '|') { result->fe_fnlen--; /* socket, whiteout, fifo */ } } #endif - + /* the caller should do this (if dropping "." and ".." is desired) if (result->fe_type == 'd' && result->fe_fname[0] == '.' && (result->fe_fnlen == 1 || (result->fe_fnlen == 2 && @@ -1261,7 +1270,7 @@ int ParseFTPList(const char *line, struct list_state *state, return '?'; */ - return result->fe_type; + return result->fe_type; } /* if (lstyle == 'U') */ @@ -1287,8 +1296,8 @@ int ParseFTPList(const char *line, struct list_state *state, * CMT.CSV 0 07-06-95 14:56 * * Chameleon dirlist guessed from lynx - * . <DIR> Nov 16 1994 17:16 - * .. <DIR> Nov 16 1994 17:16 + * . <DIR> Nov 16 1994 17:16 + * .. <DIR> Nov 16 1994 17:16 * INSTALL <DIR> Nov 16 1994 17:17 * CMT <DIR> Nov 21 1994 10:17 * DESIGN1.DOC 11264 May 11 1995 14:20 A @@ -1296,7 +1305,7 @@ int ParseFTPList(const char *line, struct list_state *state, * WPKIT1.EXE 960338 Jun 21 1995 17:01 R * CMT.CSV 0 Jul 06 1995 14:56 RHA */ - if (numtoks >= 4 && toklen[0] < 13 && + if (numtoks >= 4 && toklen[0] < 13 && ((toklen[1] == 5 && *tokens[1] == '<') || isdigit(*tokens[1])) ) { if (numtoks == 4 @@ -1310,7 +1319,7 @@ int ParseFTPList(const char *line, struct list_state *state, && isdigit(tokens[2][6]) && isdigit(tokens[2][7]) && (toklen[2] < 9 || isdigit(tokens[2][8])) && isdigit(tokens[3][toklen[3]-1]) && isdigit(tokens[3][toklen[3]-2]) - && isdigit(tokens[3][toklen[3]-4]) && isdigit(*tokens[3]) + && isdigit(tokens[3][toklen[3]-4]) && isdigit(*tokens[3]) ) { lstyle = 'w'; @@ -1333,8 +1342,8 @@ int ParseFTPList(const char *line, struct list_state *state, } if (lstyle && state->lstyle != lstyle) /* first time */ { - p = tokens[1]; - if (toklen[1] != 5 || p[0] != '<' || p[1] != 'D' || + p = tokens[1]; + if (toklen[1] != 5 || p[0] != '<' || p[1] != 'D' || p[2] != 'I' || p[3] != 'R' || p[4] != '>') { for (pos = 0; lstyle && pos < toklen[1]; pos++) @@ -1376,7 +1385,7 @@ int ParseFTPList(const char *line, struct list_state *state, for (pos = 0; pos < (12*3); pos+=3) { if (tbuf[0] == month_names[pos+0] && - tbuf[1] == month_names[pos+1] && + tbuf[1] == month_names[pos+1] && tbuf[2] == month_names[pos+2]) { result->fe_time.month = pos/3; @@ -1384,7 +1393,7 @@ int ParseFTPList(const char *line, struct list_state *state, result->fe_time.year = atoi(tokens[4]) - 1900; break; } - } + } pos = 5; /* Chameleon toknum of date field */ } else @@ -1417,7 +1426,7 @@ int ParseFTPList(const char *line, struct list_state *state, /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ #if defined(SUPPORT_DLS) /* dls -dtR */ - if (!lstyle && + if (!lstyle && (state->lstyle == 'D' || (!state->lstyle && state->numlines == 1))) /* /bin/dls lines have to be immediately recognizable (first line) */ { @@ -1442,7 +1451,7 @@ int ParseFTPList(const char *line, struct list_state *state, * size: (\-|\=|\d+)\s+ * month/day: ((\w\w\w\s+\d+|\d+\s+\w\w\w)\s+ * time/year: (\d+:\d+|\d\d\d\d))\s+ - * rest: (.+) + * rest: (.+) * * README 763 Jul 11 21:05 Information about this server * bin/ - Apr 28 1994 @@ -1455,9 +1464,9 @@ int ParseFTPList(const char *line, struct list_state *state, * TIMIT.mostlikely.Z * 79215 Jul 11 21:04 */ - if (!state->lstyle && line[linelen-1] == ':' && + if (!state->lstyle && line[linelen-1] == ':' && linelen >= 2 && toklen[numtoks-1] != 1) - { + { /* code in mirror.pl suggests that a listing may be preceded * by a PWD line in the form "/some/dir/names/here:" * but does not necessarily begin with '/'. *sigh* @@ -1492,7 +1501,7 @@ int ParseFTPList(const char *line, struct list_state *state, { p = &line[pos]; if ((*p == '-' || *p == '=' || isdigit(*p)) && - ((linelen == (pos+1)) || + ((linelen == (pos+1)) || (linelen >= (pos+3) && p[1] == ' ' && p[2] == ' ')) ) { tokmarker = 1; @@ -1505,7 +1514,7 @@ int ParseFTPList(const char *line, struct list_state *state, if ((tokens[pos]+toklen[pos]) == (&line[23])) tokmarker = pos; } - if (tokmarker) + if (tokmarker) { lstyle = 'D'; if (*tokens[tokmarker] == '-' || *tokens[tokmarker] == '=') @@ -1513,13 +1522,13 @@ int ParseFTPList(const char *line, struct list_state *state, if (toklen[tokmarker] != 1 || (tokens[tokmarker-1][toklen[tokmarker-1]-1]) != '/') lstyle = 0; - } + } else { - for (pos = 0; lstyle && pos < toklen[tokmarker]; pos++) + for (pos = 0; lstyle && pos < toklen[tokmarker]; pos++) { if (!isdigit(tokens[tokmarker][pos])) - lstyle = 0; + lstyle = 0; } } if (lstyle && !state->lstyle) /* first time */ @@ -1528,7 +1537,7 @@ int ParseFTPList(const char *line, struct list_state *state, for (p = tokens[0]; lstyle && p < &(tokens[tokmarker-1][toklen[tokmarker-1]]); p++) { - if (*p == '<' || *p == '|' || *p == '>' || + if (*p == '<' || *p == '|' || *p == '>' || *p == '?' || *p == '*' || *p == '/' || *p == '\\') lstyle = 0; } @@ -1584,8 +1593,8 @@ int ParseFTPList(const char *line, struct list_state *state, result->fe_size[pos] = '\0'; } - if ((tokmarker+3) < numtoks && - (&(tokens[numtoks-1][toklen[numtoks-1]]) - + if ((tokmarker+3) < numtoks && + (&(tokens[numtoks-1][toklen[numtoks-1]]) - tokens[tokmarker+1]) >= (1+1+3+1+4) ) { pos = (tokmarker+3); @@ -1594,7 +1603,7 @@ int ParseFTPList(const char *line, struct list_state *state, if ((pos == 4 || pos == 5) && isdigit(*p) && isdigit(p[pos-1]) && isdigit(p[pos-2]) - && ((pos == 5 && p[2] == ':') || + && ((pos == 5 && p[2] == ':') || (pos == 4 && (isdigit(p[1]) || p[1] == ':'))) ) { @@ -1606,8 +1615,8 @@ int ParseFTPList(const char *line, struct list_state *state, pos--; } p = tokens[month_num]; - if (isdigit(*tokens[pos]) - && (toklen[pos] == 1 || + if (isdigit(*tokens[pos]) + && (toklen[pos] == 1 || (toklen[pos] == 2 && isdigit(tokens[pos][1]))) && toklen[month_num] == 3 && isalpha(*p) && isalpha(p[1]) && isalpha(p[2]) ) @@ -1694,9 +1703,7 @@ int ParseFTPList(const char *line, struct list_state *state, } /* if (linelen > 0) */ - if (state->parsed_one || state->lstyle) /* junk if we fail to parse */ - return '?'; /* this time but had previously parsed successfully */ - return '"'; /* its part of a comment or error message */ + return ParsingFailed(state); } /* ==================================================================== */ @@ -1706,7 +1713,7 @@ int ParseFTPList(const char *line, struct list_state *state, #include <stdio.h> -static int do_it(FILE *outfile, +static int do_it(FILE *outfile, char *line, size_t linelen, struct list_state *state, char **cmnt_buf, unsigned int *cmnt_buf_sz, char **list_buf, unsigned int *list_buf_sz ) @@ -1715,7 +1722,7 @@ static int do_it(FILE *outfile, char *p; int rc; - rc = ParseFTPLIST( line, state, &result ); + rc = ParseFTPList( line, state, &result ); if (!outfile) { @@ -1725,16 +1732,16 @@ static int do_it(FILE *outfile, else if (rc == '"') fprintf(outfile, "cmnt: %.*s\n", (int)linelen, line ); else - fprintf(outfile, + fprintf(outfile, "list: %02u-%02u-%02u %02u:%02u%cM %20s %.*s%s%.*s\n", (result.fe_time.tm_mday ? (result.fe_time.tm_month + 1) : 0), result.fe_time.tm_mday, (result.fe_time.tm_mday ? (result.fe_time.tm_year % 100) : 0), - result.fe_time.tm_hour - + result.fe_time.tm_hour - ((result.fe_time.tm_hour > 12)?(12):(0)), result.fe_time.tm_min, ((result.fe_time.tm_hour >= 12) ? 'P' : 'A'), - (rc == 'd' ? "<DIR> " : + (rc == 'd' ? "<DIR> " : (rc == 'l' ? "<JUNCTION> " : result.fe_size)), (int)result.fe_fnlen, result.fe_fname, ((rc == 'l' && result.fe_lnlen) ? " -> " : ""), @@ -1742,10 +1749,10 @@ static int do_it(FILE *outfile, ((rc == 'l' && result.fe_lnlen) ? result.fe_lname : "") ); } else if (rc != '?') /* NOT junk */ - { + { char **bufp = list_buf; unsigned int *bufz = list_buf_sz; - + if (rc == '"') /* comment - make it a 'result' */ { memset( &result, 0, sizeof(result)); @@ -1755,18 +1762,18 @@ static int do_it(FILE *outfile, if (line[linelen-1] == '/') { result.fe_type = 'd'; - result.fe_fnlen--; + result.fe_fnlen--; } bufp = cmnt_buf; bufz = cmnt_buf_sz; rc = result.fe_type; - } + } linelen = 80 + result.fe_fnlen + result.fe_lnlen; p = (char *)realloc( *bufp, *bufz + linelen ); if (!p) return -1; - sprintf( &p[*bufz], + sprintf( &p[*bufz], "%02u-%02u-%04u %02u:%02u:%02u %20s %.*s%s%.*s\n", (result.fe_time.tm_mday ? (result.fe_time.tm_month + 1) : 0), result.fe_time.tm_mday, @@ -1774,7 +1781,7 @@ static int do_it(FILE *outfile, result.fe_time.tm_hour, result.fe_time.tm_min, result.fe_time.tm_sec, - (rc == 'd' ? "<DIR> " : + (rc == 'd' ? "<DIR> " : (rc == 'l' ? "<JUNCTION> " : result.fe_size)), (int)result.fe_fnlen, result.fe_fname, ((rc == 'l' && result.fe_lnlen) ? " -> " : ""), @@ -1829,9 +1836,9 @@ int main(int argc, char *argv[]) { appname++; break; - } + } } - fprintf(stderr, + fprintf(stderr, "Usage: %s <inputfilename> [<outputfilename>]\n" "\nIf an outout file is specified the results will be" "\nbe post-processed, and only the file entries will appear" @@ -1859,10 +1866,10 @@ int main(int argc, char *argv[]) { if (linelen > 0 && line[linelen-1] == '\n') linelen--; - if (do_it( outfile, line, linelen, &state, + if (do_it( outfile, line, linelen, &state, &cmnt_buf, &cmnt_buf_sz, &list_buf, &list_buf_sz) != 0) { - fprintf(stderr, "Insufficient memory. Listing may be incomplete.\n"); + fprintf(stderr, "Insufficient memory. Listing may be incomplete.\n"); break; } } @@ -1878,7 +1885,7 @@ int main(int argc, char *argv[]) while (linelen < sizeof(line) && line[linelen] != '\n') linelen++; fprintf(stderr, "%.*s", (int)linelen, line ); - } + } fprintf(stderr, "\n"); } } @@ -1889,7 +1896,7 @@ int main(int argc, char *argv[]) else if (cmnt_buf) fwrite( cmnt_buf, 1, cmnt_buf_sz, outfile ); } - if (list_buf) + if (list_buf) free(list_buf); if (cmnt_buf) free(cmnt_buf); diff --git a/net/third_party/parseftp/chromium.patch b/net/third_party/parseftp/chromium.patch index 4021a34..62e5514 100644 --- a/net/third_party/parseftp/chromium.patch +++ b/net/third_party/parseftp/chromium.patch @@ -1,8 +1,6 @@ -diff --git a/net/third_party/parseftp/ParseFTPList.cpp b/net/third_party/parseftp/ParseFTPList.cpp -index b9ffbdc..be099e1 100644 ---- a/net/third_party/parseftp/ParseFTPList.cpp -+++ b/net/third_party/parseftp/ParseFTPList.cpp -@@ -36,15 +36,18 @@ +--- ParseFTPList.cpp.orig 2009-09-23 09:32:45.000000000 +0200 ++++ ParseFTPList.cpp 2009-11-28 20:34:21.000000000 +0100 +@@ -36,16 +36,19 @@ * * ***** END LICENSE BLOCK ***** */ @@ -12,8 +10,10 @@ index b9ffbdc..be099e1 100644 + #include <ctype.h> -#include "plstr.h" +-#include "nsDebug.h" -#include "ParseFTPList.h" ++#include "base/logging.h" +#include "base/string_util.h" + +using base::Time; @@ -22,10 +22,10 @@ index b9ffbdc..be099e1 100644 +namespace net { + - int ParseFTPList(const char *line, struct list_state *state, - struct list_result *result ) + static inline int ParsingFailed(struct list_state *state) { -@@ -156,11 +159,9 @@ int ParseFTPList(const char *line, struct list_state *state, + if (state->parsed_one || state->lstyle) /* junk if we fail to parse */ +@@ -167,11 +170,10 @@ pos++; if (pos < linelen && line[pos] == ',') { @@ -41,7 +41,16 @@ index b9ffbdc..be099e1 100644 } } } -@@ -508,12 +509,9 @@ int ParseFTPList(const char *line, struct list_state *state, +@@ -370,7 +372,7 @@ + if (lstyle && pos < (toklen[0]-1)) + { + /* ']' was found and there is at least one character after it */ +- NS_ASSERTION(*p == ']', "unexpected state"); ++ DCHECK(*p == ']') << "unexpected state"; + pos++; + p++; + tokmarker = pos; /* length of leading "[DIR1.DIR2.etc]" */ +@@ -524,12 +526,9 @@ * So its rounded up to the next block, so what, its better * than not showing the size at all. */ @@ -49,15 +58,15 @@ index b9ffbdc..be099e1 100644 - LL_UI2L(fsz, strtoul(tokens[1], (char **)0, 10)); - LL_UI2L(factor, 512); - LL_MUL(fsz, fsz, factor); -- PR_snprintf(result->fe_size, sizeof(result->fe_size), +- PR_snprintf(result->fe_size, sizeof(result->fe_size), - "%lld", fsz); + long long size = strtoul(tokens[1], NULL, 10) * 512; + base::snprintf(result->fe_size, sizeof(result->fe_size), "%lld", + size); - } + } } /* if (result->fe_type != 'd') */ -@@ -535,17 +533,17 @@ int ParseFTPList(const char *line, struct list_state *state, +@@ -551,17 +550,17 @@ } if (month_num >= 12) month_num = 0; @@ -78,10 +87,10 @@ index b9ffbdc..be099e1 100644 + result->fe_time.second = atoi(p+3); + result->fe_time.hour = atoi(tokens[3]); + result->fe_time.minute = atoi(p); - + return result->fe_type; -@@ -678,25 +676,25 @@ int ParseFTPList(const char *line, struct list_state *state, +@@ -694,25 +693,25 @@ p = tokens[tokmarker+4]; if (toklen[tokmarker+4] == 10) /* newstyle: YYYY-MM-DD format */ { @@ -118,7 +127,7 @@ index b9ffbdc..be099e1 100644 result->fe_cinfs = 1; result->fe_fname = tokens[0]; -@@ -839,25 +837,25 @@ int ParseFTPList(const char *line, struct list_state *state, +@@ -855,25 +854,25 @@ } } @@ -157,10 +166,10 @@ index b9ffbdc..be099e1 100644 /* the caller should do this (if dropping "." and ".." is desired) if (result->fe_type == 'd' && result->fe_fname[0] == '.' && -@@ -955,13 +953,13 @@ int ParseFTPList(const char *line, struct list_state *state, +@@ -971,13 +970,13 @@ result->fe_size[pos] = '\0'; - } - + } + - result->fe_time.tm_month = atoi(&p[35-18]) - 1; - result->fe_time.tm_mday = atoi(&p[38-18]); - result->fe_time.tm_year = atoi(&p[41-18]); @@ -175,19 +184,19 @@ index b9ffbdc..be099e1 100644 + result->fe_time.year += 100; + result->fe_time.hour = atoi(&p[46-18]); + result->fe_time.minute = atoi(&p[49-18]); - + /* the caller should do this (if dropping "." and ".." is desired) if (result->fe_type == 'd' && result->fe_fname[0] == '.' && -@@ -1006,7 +1004,7 @@ int ParseFTPList(const char *line, struct list_state *state, +@@ -1022,7 +1021,7 @@ * "drwxr-xr-x 2 0 0 512 May 28 22:17 etc" */ - + - PRBool is_old_Hellsoft = PR_FALSE; + bool is_old_Hellsoft = false; - + if (numtoks >= 6) { -@@ -1034,7 +1032,7 @@ int ParseFTPList(const char *line, struct list_state *state, +@@ -1050,7 +1049,7 @@ /* rest is FMA[S] or AFM[S] */ lstyle = 'U'; /* very likely one of the NetWare servers */ if (toklen[0] == 10) @@ -196,7 +205,7 @@ index b9ffbdc..be099e1 100644 } } } -@@ -1150,10 +1148,10 @@ int ParseFTPList(const char *line, struct list_state *state, +@@ -1166,10 +1165,10 @@ result->fe_size[pos] = '\0'; } @@ -211,7 +220,7 @@ index b9ffbdc..be099e1 100644 p = tokens[tokmarker+3]; pos = (unsigned int)atoi(p); -@@ -1161,25 +1159,26 @@ int ParseFTPList(const char *line, struct list_state *state, +@@ -1177,25 +1176,27 @@ p--; if (p[2] != ':') /* year */ { @@ -227,7 +236,7 @@ index b9ffbdc..be099e1 100644 if (p[5] == ':') - result->fe_time.tm_sec = atoi(p+6); + result->fe_time.second = atoi(p+6); - + - if (!state->now_time) + if (!state->now_tm_valid) { @@ -247,10 +256,10 @@ index b9ffbdc..be099e1 100644 + if ( (( state->now_tm.month << 5) + state->now_tm.day_of_month) < + ((result->fe_time.month << 5) + result->fe_time.day_of_month) ) + result->fe_time.year--; - + } /* time/year */ - -@@ -1197,10 +1196,10 @@ int ParseFTPList(const char *line, struct list_state *state, + +@@ -1213,10 +1214,10 @@ { /* First try to use result->fe_size to find " -> " sequence. This can give proper result for cases like "aaa -> bbb -> ccc". */ @@ -263,7 +272,7 @@ index b9ffbdc..be099e1 100644 { result->fe_lname = result->fe_fname + (result->fe_fnlen - fe_size); result->fe_lnlen = (&(line[linelen])) - (result->fe_lname); -@@ -1216,7 +1215,7 @@ int ParseFTPList(const char *line, struct list_state *state, +@@ -1232,7 +1233,7 @@ p = result->fe_fname + (result->fe_fnlen - 5); for (pos = (result->fe_fnlen - 5); pos > 0; pos--) { @@ -272,8 +281,8 @@ index b9ffbdc..be099e1 100644 { result->fe_lname = p + 4; result->fe_lnlen = (&(line[linelen])) -@@ -1371,9 +1370,9 @@ int ParseFTPList(const char *line, struct list_state *state, - tbuf[1] == month_names[pos+1] && +@@ -1387,9 +1388,9 @@ + tbuf[1] == month_names[pos+1] && tbuf[2] == month_names[pos+2]) { - result->fe_time.tm_month = pos/3; @@ -284,8 +293,8 @@ index b9ffbdc..be099e1 100644 + result->fe_time.year = atoi(tokens[4]) - 1900; break; } - } -@@ -1381,17 +1380,17 @@ int ParseFTPList(const char *line, struct list_state *state, + } +@@ -1397,17 +1398,17 @@ } else { @@ -310,7 +319,7 @@ index b9ffbdc..be099e1 100644 /* the caller should do this (if dropping "." and ".." is desired) if (result->fe_type == 'd' && result->fe_fname[0] == '.' && -@@ -1607,7 +1606,7 @@ int ParseFTPList(const char *line, struct list_state *state, +@@ -1623,7 +1624,7 @@ pos = atoi(tokens[pos]); if (pos > 0 && pos <= 31) { @@ -319,7 +328,7 @@ index b9ffbdc..be099e1 100644 month_num = 1; for (pos = 0; pos < (12*3); pos+=3) { -@@ -1618,34 +1617,35 @@ int ParseFTPList(const char *line, struct list_state *state, +@@ -1634,34 +1635,36 @@ month_num++; } if (month_num > 12) @@ -347,21 +356,23 @@ index b9ffbdc..be099e1 100644 - result->fe_time.tm_hour = pos; - result->fe_time.tm_min = atoi(p+3); - if (!state->now_time) +- { +- state->now_time = PR_Now(); +- PR_ExplodeTime((state->now_time), PR_LocalTimeParameters, &(state->now_tm) ); +- } +- result->fe_time.tm_year = state->now_tm.tm_year; +- if ( (( state->now_tm.tm_month << 4) + state->now_tm.tm_mday) < +- ((result->fe_time.tm_month << 4) + result->fe_time.tm_mday) ) +- result->fe_time.tm_year--; + result->fe_time.hour = pos; + result->fe_time.minute = atoi(p+3); + if (!state->now_tm_valid) - { -- state->now_time = PR_Now(); -- PR_ExplodeTime((state->now_time), PR_LocalTimeParameters, &(state->now_tm) ); ++ { + Time t = Time::Now(); + t.LocalExplode(&(state->now_tm)); + state->now_tm.month--; + state->now_tm_valid = true; - } -- result->fe_time.tm_year = state->now_tm.tm_year; -- if ( (( state->now_tm.tm_month << 4) + state->now_tm.tm_mday) < -- ((result->fe_time.tm_month << 4) + result->fe_time.tm_mday) ) -- result->fe_time.tm_year--; ++ } + result->fe_time.year = state->now_tm.year; + if ( (( state->now_tm.month << 4) + state->now_tm.day_of_month) < + ((result->fe_time.month << 4) + result->fe_time.day_of_month) ) @@ -369,16 +380,14 @@ index b9ffbdc..be099e1 100644 } /* got year or time */ } /* got month/mday */ } /* may have year or time */ -@@ -1893,3 +1893,5 @@ int main(int argc, char *argv[]) +@@ -1907,3 +1910,5 @@ return 0; } #endif + +} // namespace net -diff --git a/net/third_party/parseftp/ParseFTPList.h b/net/third_party/parseftp/ParseFTPList.h -index 30ef8a3..b11abdc 100644 ---- a/net/third_party/parseftp/ParseFTPList.h -+++ b/net/third_party/parseftp/ParseFTPList.h +--- ParseFTPList.h.orig 2008-12-15 21:10:49.000000000 +0100 ++++ ParseFTPList.h 2009-09-27 00:53:54.000000000 +0200 @@ -35,7 +35,11 @@ * the terms of any one of the MPL, the GPL or the LGPL. * @@ -392,7 +401,7 @@ index 30ef8a3..b11abdc 100644 /* ParseFTPList() parses lines from an FTP LIST command. ** -@@ -96,28 +100,30 @@ +@@ -96,28 +100,35 @@ #define SUPPORT_OS2 /* IBM TCP/IP for OS/2 - FTP Server */ #define SUPPORT_W16 /* win16 hosts: SuperTCP or NetManage Chameleon */ @@ -439,7 +448,7 @@ index 30ef8a3..b11abdc 100644 /* (converting all-upcase names may be desirable) */ }; -@@ -125,3 +131,6 @@ int ParseFTPList(const char *line, +@@ -125,3 +136,6 @@ struct list_state *state, struct list_result *result ); |
