Skip to content

Fix prototype-named code modules#157

Draft
junaga wants to merge 1 commit into
screeps:masterfrom
junaga:agent/fix-prototype-module-names
Draft

Fix prototype-named code modules#157
junaga wants to merge 1 commit into
screeps:masterfrom
junaga:agent/fix-prototype-module-names

Conversation

@junaga

@junaga junaga commented Jul 20, 2026

Copy link
Copy Markdown

What changed

  • Store require.cache and require.initGlobals in null-prototype dictionaries.
  • Check both the cache and uploaded module map with an own-property test.
  • Add regressions for constructor, toString, and __proto__ module names, plus the corresponding unknown-module case.

Why

The loader used moduleName in require.cache while the cache inherited from Object.prototype. A module named constructor or toString was therefore treated as already cached and returned the inherited built-in instead of evaluating player code. __proto__ also could not be stored safely through ordinary object assignment.

Using dictionary objects and own-property checks makes every uploaded module name behave consistently and prevents inherited properties from masquerading as modules.

Validation

  • Full Jasmine suite: 112 specs, 0 failures
  • Gulp build completed successfully

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

Successfully merging this pull request may close these issues.

2 participants