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
3 Likes
Henry96
September 2, 2024, 5:12pm
3
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:
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)
Had the same issue here.
my expected copied text would be
Mean: 5.5
Standard Deviation: 3.0277
Coefficient of Variation: 0.5505 (55.05%)
while it gave me this:
mean: 5.5Standard Deviation: 3.0277Coefficient of Variation: 0.5505 (55.05%)
Brave version: 1.69168
Operating system: macOS
Thank you all for reporting and apologies for the long response time here. Looks like I can reproduce this on my end as well. Taking a look at this now — appreciate your patience.
fmarier
September 18, 2024, 10:16pm
6
We have had a similar report here:
opened 09:19PM - 13 Sep 24 UTC
priority/P2
QA/Yes
release-notes/include
OS/Desktop
QA/Test-All-Platforms
### Description
When I copy some of my passwords via icon on the webui, the c… haracters on the copied password coverts to the lower letters. I mean, I cannot copy and paste original password. If I make the password visible and then copy it manually via Ctrl + C or right click, I can paste it as original state without changing the letters.
The problem occurs on vault.bitwarden.com copy function via icon. I tried different browsers and there is no any problem.
Device: Apple M2 Max
OS: Sonoma 14.6.1
Brave: 2024.9.0
This problem that I face has started 10 or 12 days ago. Before that, there was no any issue. The problem occurs only one password that included ":", "^", and ",". For others, the characters stay same as expected. But for this password, let's say the password is "ASDASD:asd^ASD,ASD". When I manually copy the password there is no problem. But if I use the automatic copy function via icon on the website, it is converted to "asdasd:asd^ASD,ASD".
On the developer tools > console there is no any error. It's hard to explain the issue. I hope it's clear.
### Steps to reproduce
1. go vault.bitwarden.com
2. create a password ASDASD:asd^ASD,ASD
3. then copy it via copying icon
4. paste it somewhere and you will get the result like asdasd:asd^ASD,ASD
### Actual result
asdasd:asd^ASD,ASD
### Expected result
ASDASD:asd^ASD,ASD
### Reproduces how often
Easily reproduced
<div id="outer" style="margin-inline: auto; margin-top: 10px; min-width: 800px; width: 1152px; color: rgb(32, 33, 36); font-family: system-ui, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div id="logo" style="float: right; margin-inline-start: 40px; text-align: end; width: 180px;"><picture><img alt="Brave logo" src="chrome://theme/IDR_PRODUCT_LOGO"></picture><div id="company" style="font-size: 0.7em; text-align: end;">Brave Software Inc</div><div id="copyright" style="font-size: 0.7em; text-align: end;">Copyright © 2024 The Brave Authors. All rights reserved.</div></div>
Brave | 1.69.168 Chromium: 128.0.6613.138 (Official Build) (arm64)
-- | --
Revision | 6918a99aa67f8b2c8cfdc9a44e6ad4f9be6c5be9
OS | macOS Version 14.6.1 (Build 23G93)
JavaScript | V8 12.8.374.31
User Agent | Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36
Command Line | /Applications/Brave Browser.app/Contents/MacOS/Brave Browser --disable-domain-reliability --enable-dom-distiller --enable-distillability-service --origin-trial-public-key=bYUKPJoPnCxeNvu72j4EmPuK7tr1PAC7SHh8ld9Mw3E=,fMS4mpO6buLQ/QMd+zJmxzty/VQ6B1EUZqoCU04zoRU= --lso-url=https://no-thanks.invalid --sync-url=https://sync-v2.brave.com/v2 --variations-server-url=https://variations.brave.com/seed --variations-insecure-server-url=https://variations.brave.com/seed --flag-switches-begin --flag-switches-end --component-updater=url-source=https://go-updater.brave.com/extensions
Executable Path | /Applications/Brave Browser.app/Contents/MacOS/Brave Browser
Profile Path | /Users/melihkarasu/Library/Application Support/BraveSoftware/Brave-Browser/Profile 3
Linker | lld
Active Variations | main@91b8a9d0e33034f2368c6ed2015474b1d818a902AllowCertainClientHintsStudy:EnabledBraveAIChatEnabledStudy:EnabledBraveAdblockMobileNotificationsListDefault:EnabledBraveAdsAdEventStudy:EnabledBraveAdsConversionsStudy:EnabledBraveAdsExclusionRulesStudy:EnabledBraveAdsNewTabPageAdsStudy:EnabledBraveAdsSiteVisitStudy:EnabledBraveAdsTextClassificationPageProbabilitiesStudy:EnabledBraveAggressiveModeRetirementExperiment:DisabledBraveAutoTranslateStudy:AutoTranslateDisabledBraveCleanupSessionCookiesOnSessionRestore:DisabledBraveDebounceStudy:EnabledBraveFeedUpdateStudy:EnabledBraveForgetFirstPartyStorage:EnabledBraveGoogleSignInPermissionStudy:EnabledBraveHorizontalTabsUpdateEnabledStudy:EnabledBraveP3AConstellationEnabled:EnabledBraveP3ANebulaRelease:EnabledBraveP3ATypicalJSONDeprecationEnabled:EnabledBraveRewardsAllowSelfCustodyProvidersStudy:EnabledBraveRewardsWebUiPanelStudy:EnabledBraveScreenFingerprintingBlockerStudy:EnabledBraveSearchAdStudy:EnabledBraveWalletAnkrBalancesEnabled:DefaultBraveWebcompatExceptionsServiceReleaseStudy:EnabledClampPlatformVersionClientHint:DisabledCookieListDefaultStudy:EnabledCrossPlatformVPNStudy:EnabledDefault1pBlockingStudy:DisabledDisableReduceLanguage:EnabledEphemeralStorageStudy:EnabledExtensionsManifestV2StudyRelease:EnabledMacCoreLocationBackendStudy:EnabledPartitionedCookies:EnabledSpeedreader TTS:EnabledUndecryptablePasswords:EnabledUserActivityStudy:TriggersWhatsNewStudy:Enabled
</div><br class="Apple-interchange-newline">
a
### Channel information
- [X] release (stable)
- [ ] beta
- [ ] nightly
### Reproducibility
- [X] with Brave Shields disabled
- [ ] with Brave Rewards disabled
- [X] in the latest version of Chrome
### Miscellaneous information
_No response_
1 Like
Looks like our devs are on it and should have a fix for this soon. Thank you all again for reporting.
Henry96
September 18, 2024, 10:50pm
8
I would like to quickly mention that this issue occurs in extensions as well, not just on websites. Just to make sure the fix is applied to extensions as well.
I originally encountered this issue in an extension I maintain. Which runs as an extension popup and not as injected JS.
Extension manifest if relevant (name, description, version fields have been changed) :
{
"manifest_version": 3,
"name": "Extension title",
"description": "Extension description",
"version": "0.0.0",
"permissions": ["tabs", "storage"],
"action": {
"default_title": "Extension title",
"default_popup": "extension_menu.html",
"browser_style": true,
"icons": {
"16": "/images/icon_16.png",
"32": "/images/icon_32.png",
"48": "/images/icon_48.png",
"128": "/images/icon_128.png"
}
},
"icons": {
"16": "/images/icon_16.png",
"32": "/images/icon_32.png",
"48": "/images/icon_48.png",
"128": "/images/icon_128.png"
}
}
The extension then uses navigator.clipboard.writeText
, which currently is broken.
I added a temporary patch to the extension to allow for correct copying.
The temporary patch:
navigator.clipboard.writeText(`# Copied data (${getCurrentDateTime()})\n` + data.join("\n"))
It simply adds # Copied data ...
as the first line of the copied text, this seems to stop Brave from thinking it’s a URL that needs to be modified.
+1
This is also impacting my application
I tried putting # at the beginning of the text and it certainly doesn’t convert.
I had already tried another temporary code.
normal
navigator.clipboard.writeText(Text00)
new
navigator.clipboard.write([new ClipboardItem({‘text/plain’:new Blob([Text00],{type:‘text/plain’})})])
Copy to clipboard call eats non-printable characters. My code creates a string with \n or \r\n characters to break text up into three lines for the user.
navigator.clipboard.writeText(xxx) strips out all the non-printable characters, leaving the input text as a single line with no breaks between the original elements. This does not occur in Google Chrome or MS Edge, where the text in the buffer retains the supplied formatting.