Skip to content

Commit

Permalink
fix(replaceNonTextChars): Only replace known characters and display h…
Browse files Browse the repository at this point in the history
…ex values
  • Loading branch information
karfau committed Sep 11, 2020
1 parent 3264ccc commit 2cde39c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions xmltest.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,8 @@ const run = async (...filters) => filters.length === 0
? getEntries()
: getContent.apply(null, filters)

const replaceWithWrappedCodePointAt = char => `{!${char.codePointAt(0)}!}`
const replaceWithWrappedCodePointAt = char => `{!${char.codePointAt(0).toString(16)}!}`

/**
* Some xml documents (purposely) contain characters that are not visible
* and make it hard to reason about a test result.
Expand All @@ -294,7 +295,7 @@ const replaceWithWrappedCodePointAt = char => `{!${char.codePointAt(0)}!}`
const replaceNonTextChars = (value, wrapper = replaceWithWrappedCodePointAt) =>
value === undefined || value === ''
? value
: value.toString().replace(/[\p{Cc}\uFFFF]/gu, wrapper)
: value.toString().replace(/[\u0000\u001B\u001F\uDC00\uD800\uFFFE\uFFFF]/gu, wrapper)

module.exports = {
combineFilters,
Expand Down

0 comments on commit 2cde39c

Please sign in to comment.