Skip to content

Commit bbba3c7

Browse files
committed
fix to replace some more escape chars
1 parent 1fc39d5 commit bbba3c7

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

lib/internal/test_runner/tap_stream.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,18 @@ class TapStream extends Readable {
131131

132132
// In certain places, # and \ need to be escaped as \# and \\.
133133
function tapEscape(input) {
134-
return StringPrototypeReplaceAll(StringPrototypeReplaceAll(
135-
StringPrototypeReplaceAll(input, '\\', '\\\\'), '#', '\\#'
136-
), '\n', '\\n');
134+
[{ escapeChar: '\\', tappedEscape: '\\\\' },
135+
{ escapeChar: '#', tappedEscape: '\\#' },
136+
{ escapeChar: '\n', tappedEscape: '\\n' },
137+
{ escapeChar: '\t', tappedEscape: '\\t' },
138+
{ escapeChar: '\r', tappedEscape: '\\r' },
139+
{ escapeChar: '\f', tappedEscape: '\\f' },
140+
{ escapeChar: '\b', tappedEscape: '\\b' },
141+
{ escapeChar: '\v', tappedEscape: '\\v' },
142+
].forEach(({ escapeChar, tappedEscape }) => {
143+
input = StringPrototypeReplaceAll(input, escapeChar, tappedEscape);
144+
});
145+
return input;
137146
}
138147

139148
function jsToYaml(indent, name, value) {

0 commit comments

Comments
 (0)