kingzee / Clipboards!
Tech
31/05/26
Clipboards!
"How the hell does Discord know the file name of this picture I copied from my browser?"<br>is an example of a thought that will help me kill half an hour instead of being productive.
So, a quick surface search gives me this :
A window can place more than one object on the clipboard, each representing the same information in a different clipboard format.<br>Users need not be aware of the clipboard formats used for an object on the clipboard.
- From https://learn.microsoft.com/en-us/windows/win32/dataxchg/clipboard-formats>
And funny enough, here's what the clipboard looked like when I copied the text above :
InsideClipboard, a software that looks.. inside clipboards.
Don't get overwhelmed, it's just a screenshot of a neat software displaying all sorts of different data types. You'll understand most of it in a bit.
So to re-iterate, whenever you copy anything from anywhere, it will copy and store the information you copied in "different clipboard formats",<br>which is really just a roundabout way of saying metadata.
Every time this xkcd is quoted it creates more data
There's all sorts of extra information stored based on the type of data being copied.<br>For the definition above for example, there's the text itself, which is what you expected to copy.<br>And then there's the "HTML Format", which is still the same data, but including some HTML information.
(Shoutout to NirSoft Freeware for providing us with InsideClipboard,<br>the software helping us peep inside whatever clipboards we're going to copy in our little adventure.)
Let's now look at the HTML Format, which is twice the size of the text I just copied :
Version:0.9<br>StartHTML:00000183<br>EndHTML:00000481<br>StartFragment:00000217<br>EndFragment:00000445<br>SourceURL:https://learn.microsoft.com/en-us/windows/win32/dataxchg/clipboard-formats
A window can place more than one object on the clipboard, each representing the same information in a different clipboard format. Users need not be aware of the clipboard formats used for an object on the clipboard.
For my non-tech readers, this above is just the website's HTML structure of the text I copied. Now for the Firefox special text/_moz_htmlcontext :
This htmlcontext on the other hand, is the complete code structure of the full page surrounding the line I copied.<br>Thank you Firefox, for shipping the entire page along into my clipboard, making sure everyone understands the "context" of my 2 line shitpost.
Back to the first HTML Format : it is the de-facto standard when copying any kind of content from any browser.<br>When you copy text online, the HTML format in your clipboard will store: the text you copied, the URL that content was copied<br>from, and an HTML "fragment" from that page.
Note that "web" content here is a loose term, and theoretically any app, can serve an HTML Format with the text you copy from it.
For example, I like to use OneNote as my text editor when writing these blogs, and here's an example of what copying from<br>OneNote looks like :
Version:1.0<br>StartHTML:0000000105<br>EndHTML:0000000641<br>StartFragment:0000000588<br>EndFragment:0000000595
and then he said, I didn't ask for context, I asked for a sandwich with cheese!
OneNote is a good example because unlike Discord or VSCode, which are written in JavaScript,<br>OneNote is coded in-house by Microsoft in C++/C#, and still chooses to provide its copied text information in HTML Format too.
Any app can choose to write to your clipboard in any format.
In many cases, apps will use this HTML Format to include styling information, like the font used, the text size,<br>text color, background color, and so on.. This is good, it's in fact a great idea as to be able to move rich text<br>around with style. Still, every time you copy data, you might be carrying around a lot more information than you'd expect.
For example, why am I carrying around the "Source URL" of where my data was copied from?<br>I know damn well I'll never need to use that data when pasting my text into any app I use.<br>In any case, I'll save my privacy rants for another day. But as I was researching this,<br>I found the weirdest behavior from ChatGPT, Claude, Gemini, Grok, and Mistral AI;<br>specifically those websites; as Kimi, Deepseek, Perplexity AI, all behaved normally.
When you copy data from virtually every website online, it will copy along this source URL,<br>which is the link from where you were copying your text.
But the 5 LLM websites I just mentioned, will intentionally strip the source URL from the clipboard.<br>Gemini specifically, will ONLY strip it from responses, but not from your own prompts.
For some (stupid) reason, because this behavior also omits Firefox's "HTML context" we mentioned earlier,<br>I (stupidly) thought this unnatural behavior was caused by the browser rather than the websites.<br>So, my first reaction was to send an e-mail to the Firefox CTO (wait what), highlighting the special behavior.<br>He responded (what), asking me for more...