Use ascii lowercase for module aliases

This matches with Luau 0.686 changes
This commit is contained in:
Alex Orlenko
2025-08-09 19:14:31 +01:00
parent c035c23a15
commit bd63f63bc9
2 changed files with 8 additions and 2 deletions
+7 -1
View File
@@ -570,8 +570,14 @@ pub(super) fn create_require_function<R: Require + MaybeSend + 'static>(
unsafe extern "C-unwind" fn to_lowercase(state: *mut ffi::lua_State) -> c_int {
let s = ffi::luaL_checkstring(state, 1);
let s = CStr::from_ptr(s);
if !s.to_bytes().iter().any(|&c| c.is_ascii_uppercase()) {
// If the string does not contain any uppercase ASCII letters, return it as is
return 1;
}
callback_error_ext(state, ptr::null_mut(), true, |extra, _| {
let s = s.to_string_lossy().to_lowercase();
let s = (s.to_bytes().iter())
.map(|&c| c.to_ascii_lowercase())
.collect::<bstr::BString>();
(*extra).raw_lua().push(s).map(|_| 1)
})
}
+1 -1
View File
@@ -359,7 +359,7 @@ impl Lua {
return Err(Error::runtime("module name must begin with '@'"));
}
#[cfg(feature = "luau")]
let modname = modname.to_lowercase();
let modname = modname.to_ascii_lowercase();
unsafe {
self.exec_raw::<()>(value, |state| {
ffi::luaL_getsubtable(state, ffi::LUA_REGISTRYINDEX, LOADED_MODULES_KEY);