Permalink
Browse files

fix for escape()ing too much

  • Loading branch information...
1 parent dcd072b commit baa0daac4d53e7e70482e8a72c19d5026514c3bd @substack committed Nov 30, 2011
Showing with 8 additions and 2 deletions.
  1. +7 −1 lib/request.js
  2. +1 −1 package.json
View
@@ -26,7 +26,7 @@ Request.prototype.write = function (buf) {
this.emit('data', new Buffer(
Object.keys(headers)
.map(function (key) {
- return escape(key) + ': ' + escape(headers[key])
+ return guard(key) + ': ' + guard(headers[key])
})
.concat('', '')
.join('\r\n')
@@ -40,3 +40,9 @@ Request.prototype.end = function (buf) {
if (buf !== undefined) this.write(buf);
this.emit('end');
};
+
+function guard (s) {
+ return s.replace(/[:\r\n]/, function (x) {
+ return '%' + x.charCodeAt(0).toString(16);
+ });
+};
View
@@ -1,7 +1,7 @@
{
"name" : "pony",
"description" : "Send email.",
- "version" : "0.0.0",
+ "version" : "0.0.1",
"repository" : {
"type" : "git",
"url" : "git://github.com/substack/node-pony.git"

0 comments on commit baa0daa

Please sign in to comment.