Quirky password copy pasting issue in Firefox

Just when testing the FTP and other server connectivity, I came across a quirky issue:

When I double click the password field, it automatically select all, and I copy it, sounds nice.
It didn’t work and FileZilla told me that there’s spaces in the password.

I pasted my password to an editor and indeed saw that there’s spaces before and after the password. Selecting other fields by double clicking works perfectly.

I don’t know what this exactly is and I didn’t actually see in code why would this happen. I do have a sense that this might be why did some people claimed to have copy pasted the password but it end up not working.

This only happens in FireFox and not Chromium by the way. I use FireFox 129 and Chromium 128 as of speaking.

On which password field are you experiencing this? The password field is shown on many pages, and it would help to know which one is not working.

3 Likes

Ah yes, since modern browsers don’t support copying actual password fields, it was this one:

图片

There are at least three instances of those fields on different pages off the top of my head. It would help to know which page I should check.

3 Likes

All password fields behave like that (in my case on FF)



and something else - if you don’t click “show pass” but you copy asterisks
then there is an extra space only at the end



except the ones outside like these which are ok

2 Likes

Just to note if I click it only once then it copies correctly
if a double click is made then it adds


Maybe it can be temporarily added if the “show” button is clicked to automatically copy to the clipboard and inform the user that the password has been copied to the CB.

3 Likes

OK, I did some digging and I found the issue.

For some unknown reason, if you use a <code> tag, Firefox adds a space to the start of the string. A fix is being deployed now that solves it by just not using a code tag for this.

I never really thought about it, but a copy to clipboard button would probably be more useful to have. I’ll have to put some effort into making that work in a generic way though, it would be good to have for other data too, like usernames and server hostnames.

5 Likes

Maybe it will be useful for you because it is only 3kb https://clipboardjs.com/

I used that script here for this tool 20000 forum users - Awesome Special Event! - #3709 by Oxy

It covers all browsers, there are no problems with permissions (R/W in CB), it copies so that it keeps the formatting, and not that each browser chooses how to format (but in your case, it doesn’t matter because you need plain text).

4 Likes

I was planning to go with plain old navigator.clipboard.writeText and not use any library. But that ClipboardJS library seems useful if it turns out that clipboard management is more difficult than that.

4 Likes

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.