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

[Bug]: genTextAreaValueMutation doesn't seem to mask attribute.value #1596

Open
1 task done
sdemjanenko opened this issue Nov 8, 2024 · 2 comments
Open
1 task done
Assignees
Labels
bug Something isn't working

Comments

@sdemjanenko
Copy link

Preflight Checklist

  • I have searched the issue tracker for a bug report that matches the one I want to file, without success.

What package is this bug report for?

rrweb-snapshot

Version

2.0.0-alpha.17

Expected Behavior

I have a React app that controls a textarea by setting the value prop. RRWeb records the attribute change as well as the change event. The data looks like

Attribute change event:

{
    "adds": [],
    "attributes": [
        {
            "attributes": {
                "value": "(903) 993-7305"
            },
            "id": 121
        }
    ],
    "removes": [],
    "source": 0,
    "texts": []
} 

Input change event:

{
    "id": 121,
    "isChecked": false,
    "source": 5,
    "text": "**************"
}

I am expecting the attributes.value to be masked.

Actual Behavior

The attributes.value is unmasked. The issue appears to be in genTextAreaValueMutation, specifically the code

item.attributes.value = Array.from(
  dom.childNodes(textarea),
  (cn) => dom.textContent(cn) || '',
).join('');

There doesn't appear to be any masking logic that is applied to this value (or upstream of this function).

Steps to Reproduce

Create a controlled textarea in React.

Testcase Gist URL

No response

Additional Information

No response

@eoghanmurray
Copy link
Contributor

Could you verify that #1596 fixed things?
My tests only recreate the bug when setting the textarea value using innerText
So this will only fix things if that's what React does when you say 'setting the value prop' .

@sdemjanenko
Copy link
Author

This was coming up when I wrapped a textarea with https://www.npmjs.com/package/typed.js. In that package it has logic that looks like

replaceText(str) {
    if (this.attr) {
      this.el.setAttribute(this.attr, str);
    } else {
      if (this.isInput) {
        this.el.value = str;
      } else if (this.contentType === 'html') {
        this.el.innerHTML = str;
      } else {
        this.el.textContent = str;
      }
    }
  }

which matches your textContent comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants