Do not leak Object.prototype when checking for core modules#203
Do not leak Object.prototype when checking for core modules#203ljharb merged 2 commits intobrowserify:masterfrom
Conversation
ljharb
left a comment
There was a problem hiding this comment.
I'm not sure why toString resolution would have changed; https://github.com/browserify/resolve/blob/master/lib/core.js#L49 should already prevent any prototype leaks - meaning that this change should not be needed to make the test here pass.
The test I added in this PR fails without the patch. It's because https://github.com/browserify/resolve/blob/master/lib/core.js#L49 isn't enough, because |
|
Gotcha. In that case, can we instead fix Line 4 in cfd0bb8 isCore function on the main export)
|
|
Already done in e5b0494! |
e5b0494 to
8da1a8f
Compare
…ore modules [New] add `is-core` export
8da1a8f to
c448d08
Compare
ljharb
left a comment
There was a problem hiding this comment.
adding is-core makes this technically semver-minor :-) will merge into both master and 1.x, and release shortly.
|
Thanks! Btw, upgrading this package in |
|
hm, these go back prettttty far :-) but thanks, would be appreciated. |
…ore modules [New] add `is-core` export See #203.
|
v1.13.0 released. |
| var core = require('./core'); | ||
|
|
||
| module.exports = function isCore(x) { | ||
| return Object.prototype.hasOwnProperty.call(core, x); |
There was a problem hiding this comment.
unfortunately this introduced a bug into v1.13.0 (see #231), by changing this from a "truthy" check, to a "presence" check - and the "core" object relies on true/false to differentiate between a core module in some version of node, versus a core module in the current version of node. This was inadvertently fixed when I extracted this logic into https://npmjs.com/is-core-module.
Context:
I'm trying to use Yarn 2 (with PnP) in Babel.
Babel depends on
browserify, which depends onbrowser-resolvewhich depends on an older version ofresolvewithout PnP support (1.1.7).I tried to upgrade
resolveinbrowser-resolve, but a test started failing because it checked fortoStringresolution.Since this worked in
resolve1.1.7, was the behavior changed on purpose?