PopClip deletes custom clipboard data, causes problems with web apps

Versions
PopClip 2021.11.1, macOS 12.2.1

Description
I’m using a web app called Legend. I have been experiencing some subtle data loss, which I noticed recently, and tracked down to PopClip. I found that the same issue occurs in other web apps that use custom clipboard data types.

I tested in the latest versions of Firefox, Vivaldi (a Chrome fork), Safari, and the Electron-based desktop app.

Steps to reproduce
When I cut or copy something from Legend to the clipboard, I can see, using Clipboard Viewer, that it uses a custom clipboard data type. In addition to the usual HTML and plain text clipboard data, in Vivaldi (Chrome), as well as Legend’s desktop app (Electron) it’s org.chromium.web-custom-data, in Firefox it’s org.mozilla.custom-clipdata, and in Safari it’s com.apple.WebKit.custom-pasteboard-data.

If I then select some other text in Legend before pasting (without copying it, i.e., in order to replace it), PopClip is activated, and the custom clipboard data may disappear, being replaced by two new ones: org.nspasteboard.TransientType and org.nspasteboard.AutoGeneratedType. Both are empty.

Then, when I paste, instead of being an exact copy as I expected, the material is missing some of its special formatting, like inline code blocks and internal links. There have been times when I didn’t notice the missing data.

Further comments:

It behaves slightly differently in each browser:

  • In Vivaldi, selecting part of a line in Legend, or selecting text in another tab, doesn’t trigger the clipboard modification, even though PopClip appears. Selecting more than one line in Legend triggers the clipboard modification.
  • In the Legend Electron app (which I use most of the time), just selecting part of a line does trigger the modification and potential data loss. Selecting more than one line does too.
  • In Safari, selecting part of a line, or text in another tab, brings up PopClip, but doesn’t trigger the modification. Selecting a whole line in Legend, or more than one line, doesn’t bring up PopClip, and doesn’t trigger it.
  • In Firefox, selecting part of a line brings up PopClip and triggers the modification. Simply clicking on text in another tab (editable or not) triggers it, even though PopClip doesn’t appear. Selecting more than one line in Legend doesn’t bring up PopClip and doesn’t trigger it. Furthermore, I found that if you have the MyJDownloader extension installed, just clicking anywhere in Legend triggers the modification, although PopClip doesn’t appear.

I see the same problem with other web apps, such as Dynalist (you’ll have to Google it, apparently I can only put two links), though it acts slightly differently. For example in Firefox, just clicking anywhere in Dynalist triggers it, without PopClip appearing, while its Electron app behaves as above. With both apps, the problem can be subtle and go unnoticed, since most of the special formatting is retained through standard clipboard text or HTML pasting, while only a few things are missing.

Thanks for the report @j3ff and welcome to the forum. It is a very well written bug report.

I can confirm that when PopClip is invoked on a selection then it may modify the current pasteboard contents, typically dropping any non-standard data types. As you determined, it only happens sometimes - it depends on the context in which the selection is made.

This behaviour is very long-standing and came from taking a conservative approach to what data it would request from an app to back-up the pasteboard contents before “swizzling” the pasteboard to read the selected text contents. Essentially, PopClip triggers a Copy, reads the pasteboard, then puts back the original contents I found that some (I guess not thorougly tested) apps would crash if tried to read certain types of data from them. So, I limited the default behavoiur to a “most common” subset of data types that would not cause any apps to crash.

However you can add an app to an allowlist using the following Terminal command (the quit and restart PopClip):

defaults write com.pilotmoon.popclip AllArchiveApps -array-add com.apple.Safari

Here, com.apple.Safari is just an example app Bundle ID. You can find the Bundle ID of any app with the BundleID extension.

The app(s) to add to the list is/are the one(s) hosting Legend.

Since this behavour has been like this for over 10 years it is probably time I review it, as it would be nice to eliminate it properly.

1 Like

I think you tagged the wrong Jeff… :wink:

1 Like

Woops! :upside_down_face: Now amended

Thanks, that seems to fix it!

Any idea offhand why that JDownloader extension would cause PopClip to behave differently in Firefox? If not, don’t worry about it. I thought I might send them a bug report, but I don’t really use the extension, so I just deleted it…

1 Like

Great! Not offhand - I would need to investigate somewhat.