From e6ba8aafa84e7786f7e5fab487c30a055a1b2eb5 Mon Sep 17 00:00:00 2001 From: Pooja D P Date: Fri, 27 Nov 2020 09:26:49 -0800 Subject: [PATCH 1/2] lib: restate the code to use primordials --- lib/_http_common.js | 5 +++-- lib/internal/process/execution.js | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/_http_common.js b/lib/_http_common.js index e97670f0acaf11..00d2888e3d6e8e 100644 --- a/lib/_http_common.js +++ b/lib/_http_common.js @@ -23,6 +23,7 @@ const { MathMin, + RegExpPrototypeTest, Symbol, } = primordials; const { setImmediate } = require('timers'); @@ -217,7 +218,7 @@ const tokenRegExp = /^[\^_`a-zA-Z\-0-9!#$%&'*+.|~]+$/; * See https://tools.ietf.org/html/rfc7230#section-3.2.6 */ function checkIsHttpToken(val) { - return tokenRegExp.test(val); + return RegExpPrototypeTest(tokenRegExp, val); } const headerCharRegex = /[^\t\x20-\x7e\x80-\xff]/; @@ -228,7 +229,7 @@ const headerCharRegex = /[^\t\x20-\x7e\x80-\xff]/; * field-vchar = VCHAR / obs-text */ function checkInvalidHeaderChar(val) { - return headerCharRegex.test(val); + return RegExpPrototypeTest(headerCharRegex, val); } function cleanParser(parser) { diff --git a/lib/internal/process/execution.js b/lib/internal/process/execution.js index 314b8b0a03c161..23451de2b728e8 100644 --- a/lib/internal/process/execution.js +++ b/lib/internal/process/execution.js @@ -1,5 +1,9 @@ 'use strict'; +const { + FunctionPrototype, +} = primordials; + const path = require('path'); const { @@ -121,7 +125,7 @@ function hasUncaughtExceptionCaptureCallback() { return exceptionHandlerState.captureFn !== null; } -function noop() {} +const noop = FunctionPrototype; // XXX(joyeecheung): for some reason this cannot be defined at the top-level // and exported to be written to process._fatalException, it has to be From 9201949674ac57faa12688d99b4638116bb17784 Mon Sep 17 00:00:00 2001 From: Pooja D P Date: Sun, 29 Nov 2020 20:22:52 -0800 Subject: [PATCH 2/2] fixup: revert the changes --- lib/_http_common.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/_http_common.js b/lib/_http_common.js index 00d2888e3d6e8e..e97670f0acaf11 100644 --- a/lib/_http_common.js +++ b/lib/_http_common.js @@ -23,7 +23,6 @@ const { MathMin, - RegExpPrototypeTest, Symbol, } = primordials; const { setImmediate } = require('timers'); @@ -218,7 +217,7 @@ const tokenRegExp = /^[\^_`a-zA-Z\-0-9!#$%&'*+.|~]+$/; * See https://tools.ietf.org/html/rfc7230#section-3.2.6 */ function checkIsHttpToken(val) { - return RegExpPrototypeTest(tokenRegExp, val); + return tokenRegExp.test(val); } const headerCharRegex = /[^\t\x20-\x7e\x80-\xff]/; @@ -229,7 +228,7 @@ const headerCharRegex = /[^\t\x20-\x7e\x80-\xff]/; * field-vchar = VCHAR / obs-text */ function checkInvalidHeaderChar(val) { - return RegExpPrototypeTest(headerCharRegex, val); + return headerCharRegex.test(val); } function cleanParser(parser) {