Text changes when using clipboard.writeText

Description of the issue: The navigator.clipboard.writeText(text0) function, if text0 contains a URL, a change is made to text0 when the paste action is performed. example:
https://www.abc.com/<br>abc
changes to
https://www.abc.com/%3Cbr%3Eabc
This change happens when I update to the current version of brave, it does not happen in other browsers.
An easy way to check this is by using the w3school website test “howto_js_copy_clipboard”.
Brave Version (check About Brave): 1.69.160
Operating System: Windows 10

1 Like

I think I’m also facing the same underlying issue, for me newline characters \n are getting removed when I’m trying to copy a list of URLs, which is quite annoying… This didn’t happen in older versions of Brave.

Example of non-URLs working as expected:
Screenshot 2024-09-02 200726

Example of URLs not working as expected:

Code used in examples:

// For trying non-URLs
document.addEventListener("click", () => {
  const nonUrls = ["hello", "world", "testing"];

  navigator.clipboard
    .writeText(nonUrls.join("\n"))
    .then(() => {
      console.log(`Copied ${nonUrls.length} non-URLs`);
    })
    .catch((err) => {
      console.warn("Failed to copy non-URLs!", err);
    });
  
  navigator.clipboard
    .readText().then((copiedText) => {
      console.log(copiedText);
    });
});

// For trying URLs
document.addEventListener("click", () => {
  const urls = ["https://www.example.com/page1", "https://www.example.com/page2", "https://www.example.com/page3"];

  navigator.clipboard
    .writeText(urls.join("\n"))
    .then(() => {
      console.log(`Copied ${urls.length} URLs`);
    })
    .catch((err) => {
      console.warn("Failed to copy URLs!", err);
    });
  
    navigator.clipboard
      .readText().then((copiedText) => {
        console.log(copiedText);
      });
});

Brave version: 1.69.160
Operating System: Windows 11 (23H2)