diff --git a/package.json b/package.json index 162d80fc..604c9dab 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@highlight-run/rrweb", - "version": "0.12.11", + "version": "0.12.12", "description": "record and replay the web", "scripts": { "test": "npm run bundle:browser && cross-env TS_NODE_CACHE=false TS_NODE_FILES=true mocha -r ts-node/register -r ignore-styles -r jsdom-global/register test/**.test.ts", diff --git a/src/snapshot/snapshot.ts b/src/snapshot/snapshot.ts index 988df4fc..32b911f2 100644 --- a/src/snapshot/snapshot.ts +++ b/src/snapshot/snapshot.ts @@ -555,7 +555,12 @@ function serializeNode( 'BODY', 'NOSCRIPT', ]); - if (!IGNORE_TAG_NAMES.has(parentTagName)) { + if (!IGNORE_TAG_NAMES.has(parentTagName) && textContent) { + // We remove non-printing characters. + // For example: '‌' is a character that isn't shown visibly or takes up layout space on the screen. However if you take the length of the string, it's counted as 1. + // For example: "‌1"'s length is 2 but visually it's only taking up 1 character width. + // If we don't filter does out, our string obfuscation could have more characters than what was originally presented. + textContent = textContent.replace(/[^ -~]+/g, ''); textContent = textContent ?.split(' ')