Mr-X-GTA / YimMenu

YimMenu, a GTA V menu protecting against a wide ranges of the public crashes and improving the overall experience.
https://yim.gta.menu
GNU General Public License v2.0
81 stars 23 forks source link

[Improvement]: os.execute(url) in lua #41

Closed Deadlineem closed 1 day ago

Deadlineem commented 2 days ago

Which feature

lua_module.cpp alterations for using os.execute with ONLY a url path to a lua script with sanitization to only allow downloading .lua script files to the scripts folder, in lua, the user cannot enter a specific path to download the file to as this is all handled in the lua_module.cpp.

Lua Usage: os.execute(https://url.com/path/to/luascript.lua) Implementation: https://pastebin.com/b3zkfBNx

Reason

lua scripts should be able to have a "check for updates" button for easy updating, adding this option will allow for such things to be accomplished

Alternatively, you can do something like this with libcurl (Untested/Uninplemented Example): https://pastebin.com/BZk51yat

References: -- Button (Check for Updates) https://github.com/Deadlineem/Extras-Addon-for-YimMenu/blob/bf01e9991fdddde6ded32fbe2f4f113b2304b290/Extras-Addon.lua#L51

-- function getUpdates(file1, file2, file3) https://github.com/Deadlineem/Extras-Addon-for-YimMenu/blob/9d40cc519ec453b5c6e5e22505e976f167f04b82/Extras-data.lua#L4364

Example Video:

https://github.com/user-attachments/assets/3ce96ecd-598b-4fad-a603-c1e451bdc483

Additional context

Tested on Extras-Addon.lua, Extras-data.lua, json.lua and update.bat from my repository main (above). While the console tells me that update.bat gets downloaded, there is no actual trace of the file in the scripts folder at all, so the C++ implementation is doing its job to filter file extensions and only allow .lua files to pass through.