From bbba3c7c77e718382e484795d0dae653e49fbe5d Mon Sep 17 00:00:00 2001 From: Pulkit Gupta <76155456+pulkit-30@users.noreply.github.com> Date: Wed, 7 Dec 2022 20:53:44 +0530 Subject: [PATCH] fix to replace some more escape chars --- lib/internal/test_runner/tap_stream.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/internal/test_runner/tap_stream.js b/lib/internal/test_runner/tap_stream.js index 259e686dace629..c501f177085885 100644 --- a/lib/internal/test_runner/tap_stream.js +++ b/lib/internal/test_runner/tap_stream.js @@ -131,9 +131,18 @@ class TapStream extends Readable { // In certain places, # and \ need to be escaped as \# and \\. function tapEscape(input) { - return StringPrototypeReplaceAll(StringPrototypeReplaceAll( - StringPrototypeReplaceAll(input, '\\', '\\\\'), '#', '\\#' - ), '\n', '\\n'); + [{ escapeChar: '\\', tappedEscape: '\\\\' }, + { escapeChar: '#', tappedEscape: '\\#' }, + { escapeChar: '\n', tappedEscape: '\\n' }, + { escapeChar: '\t', tappedEscape: '\\t' }, + { escapeChar: '\r', tappedEscape: '\\r' }, + { escapeChar: '\f', tappedEscape: '\\f' }, + { escapeChar: '\b', tappedEscape: '\\b' }, + { escapeChar: '\v', tappedEscape: '\\v' }, + ].forEach(({ escapeChar, tappedEscape }) => { + input = StringPrototypeReplaceAll(input, escapeChar, tappedEscape); + }); + return input; } function jsToYaml(indent, name, value) {