From 1037442e40e6a52fb4bcc2cd6d93a3d004f8592e Mon Sep 17 00:00:00 2001 From: Lauri Piisang Date: Tue, 6 Nov 2018 16:19:07 +0000 Subject: [PATCH] http: remove obsolete function escapeHeaderValue - there are test cases which validate the useful path of the function never runs - the functionality of it is obsoleted by checkInvalidHeaderChar --- lib/_http_outgoing.js | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/lib/_http_outgoing.js b/lib/_http_outgoing.js index 67d0090d7dabf7..04a36d2be2fde3 100644 --- a/lib/_http_outgoing.js +++ b/lib/_http_outgoing.js @@ -409,7 +409,7 @@ function processHeader(self, state, key, value, validate) { function storeHeader(self, state, key, value, validate) { if (validate) validateHeaderValue(key, value); - state.header += key + ': ' + escapeHeaderValue(value) + CRLF; + state.header += key + ': ' + value + CRLF; matchHeader(self, state, key, value); } @@ -642,13 +642,6 @@ function connectionCorkNT(msg, conn) { } -function escapeHeaderValue(value) { - // Protect against response splitting. The regex test is there to - // minimize the performance impact in the common case. - return /[\r\n]/.test(value) ? value.replace(/[\r\n]+[ \t]*/g, '') : value; -} - - OutgoingMessage.prototype.addTrailers = function addTrailers(headers) { this._trailer = ''; var keys = Object.keys(headers); @@ -670,7 +663,7 @@ OutgoingMessage.prototype.addTrailers = function addTrailers(headers) { debug('Trailer "%s" contains invalid characters', field); throw new ERR_INVALID_CHAR('trailer content', field); } - this._trailer += field + ': ' + escapeHeaderValue(value) + CRLF; + this._trailer += field + ': ' + value + CRLF; } };