Socket
Socket
Sign inDemoInstall

ftp

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ftp - npm Package Compare versions

Comparing version 0.3.2 to 0.3.3

38

lib/connection.js

@@ -53,6 +53,8 @@ var fs = require('fs'),

},*/
bytesCRLF = new Buffer([13, 10]),
bytesNOOP = new Buffer('NOOP\r\n');
var FTP = module.exports = function() {
if (!(this instanceof FTP))
return new FTP();
this._socket = undefined;

@@ -349,2 +351,26 @@ this._pasvSock = undefined;

FTP.prototype.listSafe = function(path, zcomp, cb) {
if (typeof path === 'string') {
var self = this;
// store current path
this.pwd(function(err, origpath) {
if (err) return cb(err);
// change to destination path
self.cwd(path, function(err) {
if (err) return cb(err);
// get dir listing
self.list(zcomp || false, function(err, list) {
// change back to original path
if (err) return self.cwd(origpath, cb);
self.cwd(origpath, function(err) {
if (err) return cb(err);
cb(err, list);
});
});
});
});
} else
this.list(path, zcomp, cb);
};
FTP.prototype.list = function(path, zcomp, cb) {

@@ -769,3 +795,3 @@ var self = this, cmd;

// the Internet
if (ip !== self._socket.remoteAddress) {
if (self._socket && ip !== self._socket.remoteAddress) {
ip = self._socket.remoteAddress;

@@ -803,2 +829,3 @@ return reentry();

socket.once('connect', function() {
self._debug&&self._debug('[connection] PASV socket connected');
if (self.options.secure === true) {

@@ -826,3 +853,3 @@ socket = tls.connect({

if (sockerr) {
errmsg += ': ' + sockerr;
errmsg += '( ' + sockerr + ')';
sockerr = undefined;

@@ -928,3 +955,3 @@ }

var queueLen = this._queue.length;
if (!this._curReq && queueLen) {
if (!this._curReq && queueLen && this._socket && this._socket.readable) {
this._curReq = this._queue.shift();

@@ -934,4 +961,3 @@ if (this._curReq.cmd === 'ABOR' && this._pasvSocket)

this._debug&&this._debug('[connection] > ' + inspect(this._curReq.cmd));
this._socket.write(this._curReq.cmd);
this._socket.write(bytesCRLF);
this._socket.write(this._curReq.cmd + '\r\n');
} else if (!this._curReq && !queueLen && this._ending)

@@ -938,0 +964,0 @@ this._reset();

16

lib/parser.js

@@ -35,7 +35,5 @@ var WritableStream = require('readable-stream').Writable,

// support multiple terminating responses in the buffer
if (m.index) {
rest = this._buffer.substring(m.index + m[0].length);
if (rest.length)
this._buffer = this._buffer.substring(0, m.index + m[0].length);
}
rest = this._buffer.substring(m.index + m[0].length);
if (rest.length)
this._buffer = this._buffer.substring(0, m.index + m[0].length);

@@ -56,7 +54,7 @@ debug&&debug('[parser] < ' + inspect(this._buffer));

reRmLeadCode = new RegExp(reRmLeadCode, 'g');
this._buffer = this._buffer.replace(reRmLeadCode, '$1').trim();
var text = this._buffer.replace(reRmLeadCode, '$1').trim();
this._buffer = rest;
debug&&debug('[parser] Response: code=' + code + ', buffer=' + inspect(this._buffer));
this.emit('response', code, this._buffer);
this._buffer = rest;
debug&&debug('[parser] Response: code=' + code + ', buffer=' + inspect(text));
this.emit('response', code, text);
}

@@ -63,0 +61,0 @@

{ "name": "ftp",
"version": "0.3.2",
"version": "0.3.3",
"author": "Brian White <mscdex@mscdex.net>",

@@ -4,0 +4,0 @@ "description": "An FTP client module for node.js",

@@ -179,2 +179,4 @@ Description

* **listSafe**([< _string_ >path, ][< _boolean_ >useCompression, ]< _function_ >callback) - _(void)_ - Similar to list(), except the directory is temporarily changed to `path` to retrieve the directory listing. This is useful for servers that do not handle characters like spaces and quotes in directory names well for the LIST command. This function is "optional" because it relies on pwd() being available.
### Extended commands (RFC 3659)

@@ -181,0 +183,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc