Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for [Bug]: hidden inputs are not masked when maskAllInputs is enabled #1609 #1610

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/rrweb-snapshot/src/snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@
// should warn? maybe a text node isn't attached to a parent node yet?
return false;
} else {
el = dom.parentElement(node)!;

Check warning on line 285 in packages/rrweb-snapshot/src/snapshot.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

packages/rrweb-snapshot/src/snapshot.ts#L285

[@typescript-eslint/no-non-null-assertion] Forbidden non-null assertion.
}
try {
if (typeof maskTextClass === 'string') {
Expand Down Expand Up @@ -702,10 +702,10 @@
const recordInlineImage = () => {
image.removeEventListener('load', recordInlineImage);
try {
canvasService!.width = image.naturalWidth;

Check warning on line 705 in packages/rrweb-snapshot/src/snapshot.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

packages/rrweb-snapshot/src/snapshot.ts#L705

[@typescript-eslint/no-non-null-assertion] Forbidden non-null assertion.
canvasService!.height = image.naturalHeight;

Check warning on line 706 in packages/rrweb-snapshot/src/snapshot.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

packages/rrweb-snapshot/src/snapshot.ts#L706

[@typescript-eslint/no-non-null-assertion] Forbidden non-null assertion.
canvasCtx!.drawImage(image, 0, 0);

Check warning on line 707 in packages/rrweb-snapshot/src/snapshot.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

packages/rrweb-snapshot/src/snapshot.ts#L707

[@typescript-eslint/no-non-null-assertion] Forbidden non-null assertion.
attributes.rr_dataURL = canvasService!.toDataURL(

Check warning on line 708 in packages/rrweb-snapshot/src/snapshot.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

packages/rrweb-snapshot/src/snapshot.ts#L708

[@typescript-eslint/no-non-null-assertion] Forbidden non-null assertion.
dataURLOptions.type,
dataURLOptions.quality,
);
Expand Down Expand Up @@ -1284,6 +1284,7 @@
textarea: true,
select: true,
password: true,
hidden: true,
}
: maskAllInputs === false
? {
Expand Down
1 change: 1 addition & 0 deletions packages/rrweb-snapshot/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export type MaskInputOptions = Partial<{
textarea: boolean;
select: boolean;
password: boolean;
hidden: boolean;
}>;

export type SlimDOMOptions = Partial<{
Expand Down
1 change: 1 addition & 0 deletions packages/rrweb/src/record/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@
textarea: true,
select: true,
password: true,
hidden: true,
}
: _maskInputOptions !== undefined
? _maskInputOptions
Expand Down Expand Up @@ -557,7 +558,7 @@
plugins
?.filter((p) => p.observer)
?.map((p) => ({
observer: p.observer!,

Check warning on line 561 in packages/rrweb/src/record/index.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

packages/rrweb/src/record/index.ts#L561

[@typescript-eslint/no-non-null-assertion] Forbidden non-null assertion.
options: p.options,
callback: (payload: object) =>
wrappedEmit({
Expand All @@ -575,7 +576,7 @@

iframeManager.addLoadListener((iframeEl) => {
try {
handlers.push(observe(iframeEl.contentDocument!));

Check warning on line 579 in packages/rrweb/src/record/index.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

packages/rrweb/src/record/index.ts#L579

[@typescript-eslint/no-non-null-assertion] Forbidden non-null assertion.
} catch (error) {
// TODO: handle internal error
console.warn(error);
Expand Down
125 changes: 100 additions & 25 deletions packages/rrweb/test/__snapshots__/integration.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2952,16 +2952,31 @@ exports[`record integration tests > can record form interactions 1`] = `
},
{
\\"type\\": 3,
\\"textContent\\": \\"\\\\n \\",
\\"textContent\\": \\"\\\\n \\",
\\"id\\": 63
},
{
\\"type\\": 2,
\\"tagName\\": \\"input\\",
\\"attributes\\": {
\\"type\\": \\"hidden\\",
\\"value\\": \\"123456\\"
},
\\"childNodes\\": [],
\\"id\\": 64
},
{
\\"type\\": 3,
\\"textContent\\": \\"\\\\n \\",
\\"id\\": 65
}
],
\\"id\\": 18
},
{
\\"type\\": 3,
\\"textContent\\": \\"\\\\n \\\\n \\",
\\"id\\": 64
\\"id\\": 66
},
{
\\"type\\": 2,
Expand All @@ -2971,15 +2986,15 @@ exports[`record integration tests > can record form interactions 1`] = `
{
\\"type\\": 3,
\\"textContent\\": \\"SCRIPT_PLACEHOLDER\\",
\\"id\\": 66
\\"id\\": 68
}
],
\\"id\\": 65
\\"id\\": 67
},
{
\\"type\\": 3,
\\"textContent\\": \\"\\\\n \\\\n \\\\n\\\\n\\",
\\"id\\": 67
\\"id\\": 69
}
],
\\"id\\": 16
Expand Down Expand Up @@ -4936,16 +4951,31 @@ exports[`record integration tests > can use maskInputOptions to configure which
},
{
\\"type\\": 3,
\\"textContent\\": \\"\\\\n \\",
\\"textContent\\": \\"\\\\n \\",
\\"id\\": 63
},
{
\\"type\\": 2,
\\"tagName\\": \\"input\\",
\\"attributes\\": {
\\"type\\": \\"hidden\\",
\\"value\\": \\"123456\\"
},
\\"childNodes\\": [],
\\"id\\": 64
},
{
\\"type\\": 3,
\\"textContent\\": \\"\\\\n \\",
\\"id\\": 65
}
],
\\"id\\": 18
},
{
\\"type\\": 3,
\\"textContent\\": \\"\\\\n \\\\n \\",
\\"id\\": 64
\\"id\\": 66
},
{
\\"type\\": 2,
Expand All @@ -4955,15 +4985,15 @@ exports[`record integration tests > can use maskInputOptions to configure which
{
\\"type\\": 3,
\\"textContent\\": \\"SCRIPT_PLACEHOLDER\\",
\\"id\\": 66
\\"id\\": 68
}
],
\\"id\\": 65
\\"id\\": 67
},
{
\\"type\\": 3,
\\"textContent\\": \\"\\\\n \\\\n \\\\n\\\\n\\",
\\"id\\": 67
\\"id\\": 69
}
],
\\"id\\": 16
Expand Down Expand Up @@ -6763,16 +6793,31 @@ exports[`record integration tests > should mask inputs via function call 1`] = `
},
{
\\"type\\": 3,
\\"textContent\\": \\"\\\\n \\",
\\"textContent\\": \\"\\\\n \\",
\\"id\\": 63
},
{
\\"type\\": 2,
\\"tagName\\": \\"input\\",
\\"attributes\\": {
\\"type\\": \\"hidden\\",
\\"value\\": \\"******\\"
},
\\"childNodes\\": [],
\\"id\\": 64
},
{
\\"type\\": 3,
\\"textContent\\": \\"\\\\n \\",
\\"id\\": 65
}
],
\\"id\\": 18
},
{
\\"type\\": 3,
\\"textContent\\": \\"\\\\n \\\\n \\",
\\"id\\": 64
\\"id\\": 66
},
{
\\"type\\": 2,
Expand All @@ -6782,15 +6827,15 @@ exports[`record integration tests > should mask inputs via function call 1`] = `
{
\\"type\\": 3,
\\"textContent\\": \\"SCRIPT_PLACEHOLDER\\",
\\"id\\": 66
\\"id\\": 68
}
],
\\"id\\": 65
\\"id\\": 67
},
{
\\"type\\": 3,
\\"textContent\\": \\"\\\\n \\\\n \\\\n\\\\n\\",
\\"id\\": 67
\\"id\\": 69
}
],
\\"id\\": 16
Expand Down Expand Up @@ -10466,16 +10511,31 @@ exports[`record integration tests > should not record input values if maskAllInp
},
{
\\"type\\": 3,
\\"textContent\\": \\"\\\\n \\",
\\"textContent\\": \\"\\\\n \\",
\\"id\\": 63
},
{
\\"type\\": 2,
\\"tagName\\": \\"input\\",
\\"attributes\\": {
\\"type\\": \\"hidden\\",
\\"value\\": \\"******\\"
},
\\"childNodes\\": [],
\\"id\\": 64
},
{
\\"type\\": 3,
\\"textContent\\": \\"\\\\n \\",
\\"id\\": 65
}
],
\\"id\\": 18
},
{
\\"type\\": 3,
\\"textContent\\": \\"\\\\n \\\\n \\",
\\"id\\": 64
\\"id\\": 66
},
{
\\"type\\": 2,
Expand All @@ -10485,15 +10545,15 @@ exports[`record integration tests > should not record input values if maskAllInp
{
\\"type\\": 3,
\\"textContent\\": \\"SCRIPT_PLACEHOLDER\\",
\\"id\\": 66
\\"id\\": 68
}
],
\\"id\\": 65
\\"id\\": 67
},
{
\\"type\\": 3,
\\"textContent\\": \\"\\\\n \\\\n \\\\n\\\\n\\",
\\"id\\": 67
\\"id\\": 69
}
],
\\"id\\": 16
Expand Down Expand Up @@ -13580,16 +13640,31 @@ exports[`record integration tests > should record input userTriggered values if
},
{
\\"type\\": 3,
\\"textContent\\": \\"\\\\n \\",
\\"textContent\\": \\"\\\\n \\",
\\"id\\": 63
},
{
\\"type\\": 2,
\\"tagName\\": \\"input\\",
\\"attributes\\": {
\\"type\\": \\"hidden\\",
\\"value\\": \\"123456\\"
},
\\"childNodes\\": [],
\\"id\\": 64
},
{
\\"type\\": 3,
\\"textContent\\": \\"\\\\n \\",
\\"id\\": 65
}
],
\\"id\\": 18
},
{
\\"type\\": 3,
\\"textContent\\": \\"\\\\n \\\\n \\",
\\"id\\": 64
\\"id\\": 66
},
{
\\"type\\": 2,
Expand All @@ -13599,15 +13674,15 @@ exports[`record integration tests > should record input userTriggered values if
{
\\"type\\": 3,
\\"textContent\\": \\"SCRIPT_PLACEHOLDER\\",
\\"id\\": 66
\\"id\\": 68
}
],
\\"id\\": 65
\\"id\\": 67
},
{
\\"type\\": 3,
\\"textContent\\": \\"\\\\n \\\\n \\\\n\\\\n\\",
\\"id\\": 67
\\"id\\": 69
}
],
\\"id\\": 16
Expand Down
1 change: 1 addition & 0 deletions packages/rrweb/test/html/form.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<input type="password" />
</label>
<textarea>pre value</textarea>
<input type="hidden" value="123456">
</form>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -1438,9 +1438,26 @@ exports[`cross origin iframes > form.html > should map input events correctly 1`
},
{
\\"type\\": 3,
\\"textContent\\": \\"\\\\n \\",
\\"textContent\\": \\"\\\\n \\",
\\"rootId\\": 11,
\\"id\\": 75
},
{
\\"type\\": 2,
\\"tagName\\": \\"input\\",
\\"attributes\\": {
\\"type\\": \\"hidden\\",
\\"value\\": \\"123456\\"
},
\\"childNodes\\": [],
\\"rootId\\": 11,
\\"id\\": 76
},
{
\\"type\\": 3,
\\"textContent\\": \\"\\\\n \\",
\\"rootId\\": 11,
\\"id\\": 77
}
],
\\"rootId\\": 11,
Expand All @@ -1450,7 +1467,7 @@ exports[`cross origin iframes > form.html > should map input events correctly 1`
\\"type\\": 3,
\\"textContent\\": \\"\\\\n \\\\n\\\\n\\",
\\"rootId\\": 11,
\\"id\\": 76
\\"id\\": 78
}
],
\\"rootId\\": 11,
Expand Down Expand Up @@ -2451,9 +2468,26 @@ exports[`cross origin iframes > form.html > should map scroll events correctly 1
},
{
\\"type\\": 3,
\\"textContent\\": \\"\\\\n \\",
\\"textContent\\": \\"\\\\n \\",
\\"rootId\\": 11,
\\"id\\": 75
},
{
\\"type\\": 2,
\\"tagName\\": \\"input\\",
\\"attributes\\": {
\\"type\\": \\"hidden\\",
\\"value\\": \\"123456\\"
},
\\"childNodes\\": [],
\\"rootId\\": 11,
\\"id\\": 76
},
{
\\"type\\": 3,
\\"textContent\\": \\"\\\\n \\",
\\"rootId\\": 11,
\\"id\\": 77
}
],
\\"rootId\\": 11,
Expand All @@ -2463,7 +2497,7 @@ exports[`cross origin iframes > form.html > should map scroll events correctly 1
\\"type\\": 3,
\\"textContent\\": \\"\\\\n \\\\n\\\\n\\",
\\"rootId\\": 11,
\\"id\\": 76
\\"id\\": 78
}
],
\\"rootId\\": 11,
Expand Down
Loading