Comments (16)
I really have no idea why would even a clipboard library would try to load file contents.
So that it can do things like this:
There's no way to display a image without the contents of the image.
from gnome-shell-extension-clipboard-indicator.
I can't answer why the extension loads the contents of text files, rather than just displaying the filename.
Either way the bug would still exist, since I doubt there's a way for the clipboard implementation or anyone else to determine whether the mime-type is actually accurate. The source application just says "here's a blob of data, and here's the mime-type you should advertise it as".
In this case, it's just fortunate we can rely on Gio checking the content type (somewhat slowly) and not have to trust the mime-type.
from gnome-shell-extension-clipboard-indicator.
Thank you so much for the detailed explanation @Tudmotu, and thanks @andyholmes for the fix!
Will be there a release including this fix on the extensions website soon?
from gnome-shell-extension-clipboard-indicator.
Yeah technically the interface supports multiple mimetypes, both Wayland and X11 have multi-mimetype implementations but SelectionSourceMemory
in Mutter doesn't. And since the Wayland/X11 implementations are not exposed via Gjs, this extension cannot utilize them, and we must add support in the Mutter implementation, which is exposed.
from gnome-shell-extension-clipboard-indicator.
As I said, I'm not an js
expert or even competent and it may be nonsense, but can that be caused by this line?
from gnome-shell-extension-clipboard-indicator.
Thank you @Edu4rdSHL for reporting this.
@andyholmes would you mind explaining why does this happen (I assume you understand because you fixed it)? I cannot understand how would the extension execute a command 😳
from gnome-shell-extension-clipboard-indicator.
To be honest, I didn't trace it all the way down. The only thing that makes sense is that GdkPixbuf
takes the bytes it's given and somehow ends up executing it.
I guess maybe some image formats, like maybe animated GIFs, are executables in some sense so it's capable of doing that? It sure sounds like something ridiculous an image processing library would do :/
from gnome-shell-extension-clipboard-indicator.
The thing is that it's opening binary files too, such as /usr/bin/ls
, and it's happening when a specific mimetype is found. I really have no idea why would even a clipboard library would try to load file contents.
from gnome-shell-extension-clipboard-indicator.
I would even be that optimistic that if the affected mimetype is removed from the list, the issue wouldn't happen anymore, but that just a naive assumption.
from gnome-shell-extension-clipboard-indicator.
Yeah, I understand it for images, but why for a UTF-8 string.
from gnome-shell-extension-clipboard-indicator.
Oh damn, ok.
It would be weird for Pixbuf to execute the binary data but that sounds like a possible explanation and I have no alternative explanation.
@Edu4rdSHL I think it's like this:
- The extension saves the mime type for every entry. That mime type is usually "text/plain" or "image/png", etc
- Sometimes the mime type is "UTF8_STRING". Not sure why. Anyway I had to add support for it because some applications advertise their content as "UTF8_STRING" even though it's not an actual mime type
- The extension also displays image previews in the clipboard. It identifies entries that have an image mime type and creates a small thumbnail using
St.Icon
- In order to not bloat the JSON file, the extension saves the image to a file, and saves the path of the file in the JSON
- To create the thumbnail, the extension loads the contents of the file, using the path from the JSON
The [incomplete] theory goes like this: sometimes, the extensions tries to create an St.Icon
from a file that is not an image.
For this to happen, two things need to coincide:
- You copy a string of a path
- The extension identifies the entry as an image
If these two things happen, the extension will load the binary data of the path you copied and try to create an St.Icon
from it.
What I'm still missing here is: Why does the extension identify the UTF8_STRING
as an image that should be loaded into a thumbnail? I can't see where the bug is.
But I understand how @andyholmes' solution solves this.
from gnome-shell-extension-clipboard-indicator.
@Edu4rdSHL Yes, I uploaded it to e.g.o now:
https://extensions.gnome.org/review/53581
It might take a bit before it's approved.
from gnome-shell-extension-clipboard-indicator.
Thanks! I will try to get it approved asap with the extensions team.
from gnome-shell-extension-clipboard-indicator.
Sometimes the mime type is "UTF8_STRING". Not sure why. Anyway I had to add support for it because some applications advertise their content as "UTF8_STRING" even though it's not an actual mime type
Ah, I found this in St.Clipboard
some time ago:
const char *supported_mimetypes[] = {
"text/plain;charset=utf-8",
"UTF8_STRING",
"text/plain",
"STRING",
};
I would not count on that being a complete list though, because honestly why are there four to begin with, and charset=
sure looks like it could hold other values :/
from gnome-shell-extension-clipboard-indicator.
Yeah, currently the extension tries to mimic St.Clipboard
by choosing the mimetype based on a hard-coded list and querying the clipboard for these mimetypes until it finds one that has a value.
I hope this will be solved once I get to implementing the multi-mimetype support in Mutter. Unfortunately I'm not sure when I'll get to that.
Once Mutter has multi-mimetype support, this extension will no longer be opinionated on which mimetype it should keep in the history file ― it would just keep all of them. Right now it kind of "guesses" which mimetype is the most appropriate (based on the first mimetype that returns a value from the clipboard).
from gnome-shell-extension-clipboard-indicator.
Ah gotcha, that would be good. I didn't realize Mutter was missing that, since I believe the portal-side advertises API support.
from gnome-shell-extension-clipboard-indicator.
Related Issues (20)
- Paste button pastes the contents of the clipboard in place of the selected item in the history
- [BUG] pop up notification no working. HOT 6
- Shortcuts HOT 8
- image support doesn´t work HOT 1
- Doesn't work due to clipboard entry parsing HOT 10
- Unhandled promise rejection. To suppress this warning ..
- Encoding problems HOT 4
- "Copied to clipboard" notification appears every time I copy anything, with no option to disable it HOT 1
- [BUG]: Unhandled promise rejection HOT 7
- "Text will be here" is displayed in the tray and nothing happens by clicking on it. HOT 26
- Lag - Delay HOT 5
- Suggestion: make it work as Win+V on windows HOT 2
- [BUG] In-menu keyboard controls do not work HOT 2
- Scroll Bar is Inaccessible To Mouse HOT 1
- shows sensitive information on next and previous entries HOT 2
- Non-Latin characters doesn't work HOT 2
- History clears on screenlock HOT 1
- Feature Request: Paste on Select in Clipboard Indicator
- Extension doesn't work any more HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gnome-shell-extension-clipboard-indicator.