File tree Expand file tree Collapse file tree 8 files changed +740
-3
lines changed Expand file tree Collapse file tree 8 files changed +740
-3
lines changed Original file line number Diff line number Diff line change @@ -554,6 +554,11 @@ function serializeNode(
554554 keepIframeSrcFn,
555555 newlyAddedElement,
556556 rootId,
557+ maskAllText,
558+ maskTextClass,
559+ unmaskTextClass,
560+ maskTextSelector,
561+ unmaskTextSelector,
557562 } ) ;
558563 case n . TEXT_NODE :
559564 return serializeTextNode ( n as Text , {
@@ -683,6 +688,11 @@ function serializeElementNode(
683688 */
684689 newlyAddedElement ?: boolean ;
685690 rootId : number | undefined ;
691+ maskAllText : boolean ;
692+ maskTextClass : string | RegExp ;
693+ unmaskTextClass : string | RegExp ;
694+ maskTextSelector : string | null ;
695+ unmaskTextSelector : string | null ;
686696 } ,
687697) : serializedNode | false {
688698 const {
@@ -698,6 +708,11 @@ function serializeElementNode(
698708 keepIframeSrcFn,
699709 newlyAddedElement = false ,
700710 rootId,
711+ maskAllText,
712+ maskTextClass,
713+ unmaskTextClass,
714+ maskTextSelector,
715+ unmaskTextSelector,
701716 } = options ;
702717 const needBlock = _isBlockedElement ( n , blockClass , blockSelector ) ;
703718 const tagName = getValidTagName ( n ) ;
@@ -752,12 +767,21 @@ function serializeElementNode(
752767 attributes . type !== 'button' &&
753768 value
754769 ) {
770+ const forceMask = needMaskingText (
771+ n ,
772+ maskTextClass ,
773+ maskTextSelector ,
774+ unmaskTextClass ,
775+ unmaskTextSelector ,
776+ maskAllText ,
777+ ) ;
755778 attributes . value = maskInputValue ( {
756779 type : attributes . type ,
757780 tagName,
758781 value,
759782 maskInputOptions,
760783 maskInputFn,
784+ forceMask,
761785 } ) ;
762786 } else if ( checked ) {
763787 attributes . checked = checked ;
Original file line number Diff line number Diff line change @@ -153,17 +153,20 @@ export function maskInputValue({
153153 type,
154154 value,
155155 maskInputFn,
156+ forceMask,
156157} : {
157158 maskInputOptions : MaskInputOptions ;
158159 tagName : string ;
159160 type : string | number | boolean | null ;
160161 value : string | null ;
161162 maskInputFn ?: MaskInputFn ;
163+ forceMask ?: boolean ;
162164} ) : string {
163165 let text = value || '' ;
164166 if (
165167 maskInputOptions [ tagName . toLowerCase ( ) as keyof MaskInputOptions ] ||
166- maskInputOptions [ type as keyof MaskInputOptions ]
168+ maskInputOptions [ type as keyof MaskInputOptions ] ||
169+ forceMask
167170 ) {
168171 if ( maskInputFn ) {
169172 text = maskInputFn ( text ) ;
Original file line number Diff line number Diff line change @@ -353,6 +353,7 @@ function record<T = eventWithTime>(
353353 unmaskTextSelector,
354354 inlineStylesheet,
355355 maskAllInputs : maskInputOptions ,
356+ maskInputFn,
356357 maskTextFn,
357358 slimDOM : slimDOMOptions ,
358359 dataURLOptions,
Original file line number Diff line number Diff line change @@ -511,12 +511,21 @@ export default class MutationBuffer {
511511 const target = m . target as HTMLElement ;
512512 let value = ( m . target as HTMLElement ) . getAttribute ( m . attributeName ! ) ;
513513 if ( m . attributeName === 'value' ) {
514+ const forceMask = needMaskingText (
515+ m . target ,
516+ this . maskTextClass ,
517+ this . maskTextSelector ,
518+ this . unmaskTextClass ,
519+ this . unmaskTextSelector ,
520+ this . maskAllText ,
521+ ) ;
514522 value = maskInputValue ( {
515523 maskInputOptions : this . maskInputOptions ,
516524 tagName : ( m . target as HTMLElement ) . tagName ,
517525 type : ( m . target as HTMLElement ) . getAttribute ( 'type' ) ,
518526 value,
519527 maskInputFn : this . maskInputFn ,
528+ forceMask,
520529 } ) ;
521530 }
522531 if (
Original file line number Diff line number Diff line change 1- import { MaskInputOptions , maskInputValue , Mirror } from 'rrweb-snapshot' ;
1+ import {
2+ MaskInputOptions ,
3+ maskInputValue ,
4+ Mirror ,
5+ needMaskingText ,
6+ } from 'rrweb-snapshot' ;
27import type { FontFaceSet } from 'css-font-loading-module' ;
38import {
49 throttle ,
@@ -339,6 +344,11 @@ function initInputObserver({
339344 maskInputFn,
340345 sampling,
341346 userTriggeredOnInput,
347+ maskAllText,
348+ maskTextClass,
349+ unmaskTextClass,
350+ maskTextSelector,
351+ unmaskTextSelector,
342352} : observerParam ) : listenerHandler {
343353 function eventHandler ( event : Event ) {
344354 let target = getEventTarget ( event ) ;
@@ -363,20 +373,30 @@ function initInputObserver({
363373 }
364374 let text = ( target as HTMLInputElement ) . value ;
365375 let isChecked = false ;
376+ const forceMask = needMaskingText (
377+ target as Node ,
378+ maskTextClass ,
379+ maskTextSelector ,
380+ unmaskTextClass ,
381+ unmaskTextSelector ,
382+ maskAllText ,
383+ ) ;
366384 if ( type === 'radio' || type === 'checkbox' ) {
367385 isChecked = ( target as HTMLInputElement ) . checked ;
368386 } else if (
369387 maskInputOptions [
370388 ( target as Element ) . tagName . toLowerCase ( ) as keyof MaskInputOptions
371389 ] ||
372- maskInputOptions [ type as keyof MaskInputOptions ]
390+ maskInputOptions [ type as keyof MaskInputOptions ] ||
391+ forceMask
373392 ) {
374393 text = maskInputValue ( {
375394 maskInputOptions,
376395 tagName : ( target as HTMLElement ) . tagName ,
377396 type,
378397 value : text ,
379398 maskInputFn,
399+ forceMask,
380400 } ) ;
381401 }
382402 cbWithDedup (
You can’t perform that action at this time.
0 commit comments