Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ var curl = function(url, options, callback) {
var opts = new optionsBuilder();
options = opts.follow_redirects().silent().max_redirs(5).connect_timeout(5);
}

if (/[`$&{}[;|]/g.test(url)) {
return callback(new Error('Invalid Url'), null, null);
}

var curlString = 'curl "' + url + '" ';

Expand Down
7 changes: 6 additions & 1 deletion tests/testCurl.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,9 @@ curl("www.google.com", opts, function(err, resp) {
})

opts.follow_redirects(false);
assert.equal(opts.stringify().trim(), "-v -S -k --proxy-ntlm -ntlm --connect-timeout 3 --max-redirs 10");
assert.equal(opts.stringify().trim(), "-v -S -k --proxy-ntlm -ntlm --connect-timeout 3 --max-redirs 10");

curl("www.google.com' & touch test.txt #'", function(err, resp) {
assert.notEqual(err, null, "there should be errors from curling with unsafe url");
assert.equal(resp, null, "curling with unsafe url should return error");
});