Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Environments and lua_Reader cannot be used together #1628

Open
MehradN opened this issue Sep 15, 2024 · 0 comments
Open

Environments and lua_Reader cannot be used together #1628

MehradN opened this issue Sep 15, 2024 · 0 comments

Comments

@MehradN
Copy link

MehradN commented Sep 15, 2024

The problem:

Currently (in sol2 version 3.3.0) there is no way to use sol::environment and lua_Reader together. sol::state::safe_script doesn't have an overload that can accept both, and sol::set_environment doesn't accept sol::load_result.

Why I have this problem:

I'm using Sol in an environment that I can't make any assumptions about the provided scripts. I'm planning to utilize sol::environment to prevent scripts from calling potentially dangerous functions that are provided by the Lua libraries. I can't be sure that the loaded scripts are small enough to fit in the ram, so loading all of the script to a std::string is not a viable option, and I might need to load scripts from non-conventional sources in the future, so loading the script using sol::state::safe_script_file is not a viable option either. So my only option is to use lua_Reader.

Possible solutions

  • Adding an overload to sol::state::(safe_)script that accepts lua_Reader and sol::environment at the same time.
  • Allowing sol::environment::set_on and sol::set_environment to accept sol::load_result.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant