Closed ARitz-Cracker closed 9 months ago
privacy concerns; just make your own "clipboard" with lua
^
What if I want to copy text from the chatbox or outside GMod to paste somewhere on my menu? If we're that paranoid over privacy concerns, can't we clear the clipboard on game startup?
What if someone copies something while the game is running?
What's wrong with ctrl-v?
I currently am coding something that everything is handled within a 2D3D menu, the goal is for it to be fully immersive without it opening up any sort of dialogue box. I could have a paste button where it opens up a Derma_StringRequest but I'm a perfectionist and I want CTRL+V to work with my system. CTRL+C and CTRL+X would work since we have the set function.
But I see other people's point. Something could be getting clipboards every frame like a malicious server or something. It would be a very useful feature for legitimate users. Maybe the user can choose what addon can access the clipboard?
Or (a worse idea) is to notify the user when an addon calls that function... but spam... and... it really makes this a bigger idea than it should be.
Writing a hook that constantly scans for CTRL + C or X is almost just as intrusive imo.
Compromise: A hook that's called when the user presses CTRL + V ingame.
Just do it quickly, Isn't it easy?
... the text would go nowhere because a text box isn't being selected.
Writing a hook that constantly scans for CTRL + C or X is almost just as intrusive imo.
There is no way to get text selected from outside Garry's Mod, nor any text in the clipboard. This is hardly intrusive. The compromise that @DaaOtt and @zerfgog were talking about is to make your own clipboard system that copies text from text elements in-game, or whenever Control V is pressed (meaning the user intentionally wanted to paste data in). This effectively stops any lua scripts from 'accidentally' or 'intentionally' getting sensitive clipboard data, while still being able to get "clipboard" information.
I understand the compromise, but if the user wants to copy something from the chatbox, and I know that CTRL+X or C is pressed, I won't know what text is currently being selected.
@Velkon, the default in-game chatbox has a scrollbar. Unless you want to emulate the whole chatbox, including the scrolling system in order to get the text the mouse is over (which is overkill and too much effort), those functions are pointless.
@ARitz-Cracker, mm. Yeah, there is no non-hacky way to get that to work. To be completely honest, a GetClipboardText function would be awesome, but there's no reliable way to prevent sensitive data from being passed into a lua script. I don't usually copy my own passwords, credit card numbers or addresses, but I don't want to regret having done so on a malicious server that logs all clipboard information without my knowledge.
@ARitz-Cracker When you ctrl+c/x on a chatbox, doesn't the text go to your system clipboard? From there you can just have the user ctrl+v to paste into whatever.
@zerfgog I am not a derma text box or anything like that, I am a 3D2D system.
I see your point
On second thought https://wiki.garrysmod.com/page/Panel/Paste could do something with that
Aha! lmfao:
-- untested
local dummy = vgui.Create("DTextEntry")
dummy:ParentToHUD()
dummy:Hide()
dummy:SetText("")
function GetClipboardText()
dummy:Paste()
local contents = dummy:GetText()
dummy:SetText("")
return contents
end
@zerfgog I was just about to comment on doing something like that. (Nice, btw!)
But if we could do it in a hackish way, why not do it in a clean way?
Code works, btw. :D thanks for the hack!
np, privacy concerns though D:
Had to be modified a bit since Derma sometimes doesn't work right when autorun is loaded.
local dummy
hook.Add("InitPostEntity", "Privacy Stealer", function()
dummy = vgui.Create("DTextEntry")
dummy:ParentToHUD()
dummy:Hide()
dummy:SetText("")
end )
function GetClipboardText()
local contents
if dummy then
dummy:Paste()
contents = dummy:GetText()
dummy:SetText("")
end
return contents
end
I love mature server owners such as @noiwex looking at my potentially confidential information
I usually don't clear my clipboard after taking a screenshot with sharex. I screencap/upload some private stuff sometimes.
@Noiwex Christ are you on cocaine? ShareX sets your clipboard to the url of the screencapped image. How is this issue posted "for the sake of attention"? It's a valid request.
IT WAS AN EXAMPLE. Are you telling me that you clear your clipboard manually after every piece of sensitive or personal information that you copy?
Well, I stand corrected. However, imagine a DarkRP server with 45-50 players consistently, with an owner who grabs all the users' clipboard text and uses regex to find if they're an image or a chat log, then logs them if they are.
Is Microsoft willing to dox or blackmail you over those links?
There's a difference between a random dude on the internet stealing your passwords and a massive corporation stealing your passwords.
Nice rebuttal.
Yeah, because everyone is obviously less important then you are.
Instead of whining you could've helped finding a solution. This is in your own interests.
Noi pay attention to what's going on. You've been banned from the github for a reason, lots of people are arguing with you for a reason.
You're wrong. Take a look in the mirror and realize the problem isn't other people, its you. You're letting your emotions speak first and not thinking what you say though. Calm down and think/test things before you post on fp/github and people will take you more seriously.
Usually I like to give benefit of the doubt, but petty arguments like this only make me realize more why we can't trust everyone with power like this. The argument that we should have access to private data because the big guys do it is a terrible argument. I always believe that as an indie guy building himself up for his future, I should always do better than the idiots before me. Both with morals, and skills. This is a useful good feature, but it needs some enforcement in place to make sure idiots on a power trip don't... well... go on a power trip.
How about... a hook? A function that is called while the game is in focus and the player presses CTRL + V (or CMD + V on mac) It can still be a bit harmful I admit since you don't know what addon is getting the pasted information, but at least information is being handed to GMod when the user expects it.
With the addition of the permission system this should be reconsidered.
Not only others I see..
So, we can set the clipboard, why can't we get it? What if I want a "paste" button in a 2D3D menu beside a "copy" button?