mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
Fix issues with integer environment variables
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
// ** Update the version number when any breaking changes are made to the cache format or to the JS parser **
|
||||
const expected_version = 1;
|
||||
|
||||
const bun = @import("root").bun;
|
||||
const std = @import("std");
|
||||
const Output = bun.Output;
|
||||
const JSC = bun.JSC;
|
||||
const expected_version = 1;
|
||||
|
||||
const debug = Output.scoped(.cache, false);
|
||||
const MINIMUM_CACHE_SIZE = 50 * 1024;
|
||||
|
||||
@@ -135,7 +135,26 @@ JSValue createEnvironmentVariablesMap(Zig::GlobalObject* globalObject)
|
||||
hasTZ = true;
|
||||
continue;
|
||||
}
|
||||
object->putDirectCustomAccessor(vm, Identifier::fromString(vm, name), JSC::CustomGetterSetter::create(vm, jsGetterEnvironmentVariable, jsSetterEnvironmentVariable), JSC::PropertyAttribute::CustomAccessor | 0);
|
||||
ASSERT(len > 0);
|
||||
|
||||
Identifier identifier = Identifier::fromString(vm, name);
|
||||
|
||||
// CustomGetterSetter doesn't support indexed properties yet.
|
||||
// This causes strange issues when the environment variable name is an integer.
|
||||
if (UNLIKELY(chars[0] >= '0' && chars[0] <= '9')) {
|
||||
if (auto index = parseIndex(identifier)) {
|
||||
ZigString valueString = { nullptr, 0 };
|
||||
ZigString nameStr = toZigString(name);
|
||||
JSValue value = jsUndefined();
|
||||
if (Bun__getEnvValue(globalObject, &nameStr, &valueString)) {
|
||||
value = jsString(vm, Zig::toStringCopy(valueString));
|
||||
}
|
||||
object->putDirectIndex(globalObject, *index, value, 0, PutDirectIndexLikePutDirect);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
object->putDirectCustomAccessor(vm, identifier, JSC::CustomGetterSetter::create(vm, jsGetterEnvironmentVariable, jsSetterEnvironmentVariable), JSC::PropertyAttribute::CustomAccessor | 0);
|
||||
}
|
||||
|
||||
unsigned int TZAttrs = JSC::PropertyAttribute::CustomAccessor | 0;
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
/// ** IMPORTANT **
|
||||
/// ** When making changes to the JavaScript Parser that impact runtime behavior or fix bugs **
|
||||
/// ** you must also increment the `expected_version` in RuntimeTranspilerCache.zig **
|
||||
/// ** IMPORTANT **
|
||||
pub const std = @import("std");
|
||||
pub const logger = @import("root").bun.logger;
|
||||
pub const js_lexer = bun.js_lexer;
|
||||
|
||||
Reference in New Issue
Block a user