Permalink
Browse files

fix parseEntry#parsers.msdos bug,when dir name is numbers,it will be …

…read as file
  • Loading branch information...
keel committed Nov 7, 2015
1 parent 6412199 commit 0b130bc927afec17c593f5b276a434d0a11e6e68
Showing with 16 additions and 7 deletions.
  1. +1 −0 .gitignore
  2. +15 −7 src/parser.js
View
@@ -1,3 +1,4 @@
.DS_Store
.idea
node_modules
reports
View
@@ -52,6 +52,13 @@ var RE_UnixEntry = new RegExp(
var RE_DOSEntry = new RegExp(
"(\\S+)\\s+(\\S+)\\s+" +
"(<DIR>)?\\s*" +
// "([0-9]+)?\\s*" +
"(\\S.*)"
);
// fix: RE_DOSEntry2 for dir is numbers
var RE_DOSEntry2 = new RegExp(
"(\\S+)\\s+(\\S+)\\s+" +
// "(<DIR>)?\\s*" +
"([0-9]+)?\\s*" +
"(\\S.*)"
);
@@ -265,7 +272,9 @@ var parsers = {
},
msdos: function(entry) {
var group = entry.match(RE_DOSEntry);
var isDir = (entry.indexOf('<DIR>') > 0);
var regx = isDir ? RE_DOSEntry : RE_DOSEntry2;
var group = entry.match(regx);
var type;
if (!group) {
@@ -278,19 +287,18 @@ var parsers = {
var time = group[2].replace(/(\d{2}):(\d{2})([AP]M)/, replacer);
var date = new Date(group[1] + " " + time).getTime();
var dirString = group[3];
var size = group[4];
var name = group[5];
var size = group[3] || 0;
var name = group[4];
if (null == name || name === "." || name === "..") {
return null;
}
if (dirString === "<DIR>") {
if (isDir) {
type = exports.nodeTypes.DIRECTORY_TYPE;
size = 0;
}
else {
}else {
type = exports.nodeTypes.FILE_TYPE;
}

2 comments on commit 0b130bc

@keel

This comment has been minimized.

Show comment
Hide comment
@keel

keel Nov 7, 2015

Owner

When the remote dir is numbers, it will be parsed as file.
ftp server is Windows.

Owner

keel replied Nov 7, 2015

When the remote dir is numbers, it will be parsed as file.
ftp server is Windows.

@Xuanwo

This comment has been minimized.

Show comment
Hide comment
@Xuanwo

Xuanwo Dec 21, 2015

Hello, this problem only display on win server?
And had the upsteam fixed this bug yet?

Xuanwo replied Dec 21, 2015

Hello, this problem only display on win server?
And had the upsteam fixed this bug yet?

Please sign in to comment.