diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..d63ba09 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,5 @@ +language: node_js +node_js: + - 0.8 + - 0.10 + - 0.11 diff --git a/History.md b/History.md index 8a6a8b8..676ce62 100644 --- a/History.md +++ b/History.md @@ -1,4 +1,13 @@ +## v0.2.6 - 05/30/2013 + + * Fix shell injection vulnerability. [psanford](https://github.com/psanford) + * bump gleak; + +## v0.2.5 - 03/05/2012 + + * fixed; npm warning [boozedog] + ## v0.2.4 - 05/24/2011 add Punycode TLD support diff --git a/README.md b/README.md index a803c30..1a6f992 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,15 @@ +# DEPRECATED + +This project is not maintained. + +--- + # node-email A simple wrapper for the sendmail command +[![Build Status](https://travis-ci.org/aheckmann/node-email.png?branch=master)](https://travis-ci.org/aheckmann/node-email) + ## Installation First make sure [Sendmail](http://www.sendmail.org/) is installed. @@ -15,7 +23,7 @@ or git clone git://github.com/aheckmann/node-email.git ## Examples - var Email = require('path/to/email').Email + var Email = require('email').Email var myMsg = new Email( { from: "me@example.com" , to: "you@example.com" @@ -30,7 +38,7 @@ or In this example we set the global `from` property so that all email is sent from the same address. - var lib = require('path/to/email') + var lib = require('email') , Email = lib.Email; lib.from = 'someAddress@youAlwaysSendFrom.com' diff --git a/index.js b/index.js index 8ceb637..3ec2d67 100644 --- a/index.js +++ b/index.js @@ -5,7 +5,7 @@ * Module dependencies. */ -var exec = require('child_process').exec; +var spawn = require('child_process').spawn; /** * Generates a boundry string. @@ -84,11 +84,19 @@ Email.prototype = { send: function (callback) { if (!this.valid(callback)) return; - exec(this.cmd, this.options, callback); - } + var sendmail = spawn(this.path, ['-i', '-t'], this.options); + sendmail.on('exit', function(code) { + var err = null; + if (code !== 0) { + err = new Error("Sendmail exited with code: " + code); + } -, get cmd () { - return 'echo "' + this.msg + '" | ' + this.path + ' -t'; + if (callback) { + callback(err); + } + }); + + sendmail.stdin.end(this.msg); } , get options () { @@ -360,4 +368,3 @@ exports.version = '0.2.4'; exports.from = undefined; exports.timeout = 3000; exports.isValidAddress = isValidAddress; - diff --git a/package.json b/package.json index b63b9ac..155ab93 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,14 @@ { "name": "email" , "description": "A simple wrapper for sendmail." -, "version": "0.2.4" +, "version": "0.2.6" , "author": "Aaron Heckmann " , "keywords": ["email", "sendmail", "node-email"] , "engines": { "node": ">= 0.1.92" } -, "bugs": "http://github.com/aheckmann/node-email/issues" +, "bugs": { "url": "http://github.com/aheckmann/node-email/issues" } , "licenses": [{ "type": "MIT", "url": "http://www.opensource.org/licenses/mit-license.php" }] , "main": "./index" , "repository": { "type": "git", "url": "git://github.com/aheckmann/node-email.git" } +, "devDependencies": { + "gleak": "0.4.0" + } } diff --git a/test/index.js b/test/index.js index 3039fbc..cdbb060 100644 --- a/test/index.js +++ b/test/index.js @@ -1,6 +1,7 @@ var assert = require('assert') , lib = require('../') + , gleak = require('gleak')() , Email = lib.Email lib.timeout = 10000 @@ -239,4 +240,7 @@ assert.ok(lib.isValidAddress("&*=?^+{}'~@validCharsInLocal.net"), "Email address assert.ok(lib.isValidAddress("email@domain.newTLD"), "Email address should be valid (new TLD)") assert.ok(lib.isValidAddress("email@domain.рф"), "Email address should be valid (puny Code)") +var leaks = gleak.detect(); +assert.equal(leaks.length, 0); + console.log("\u001B[32mAll tests passed\u001B[0m")