Skip to content

Commit 16ead22

Browse files
committed
lib: use StringPrototypeStartsWith from primordials in locks
Use StringPrototypeStartsWith from primordials instead of String.prototype.startsWith to prevent prototype pollution. Refs: #59699
1 parent 5d39030 commit 16ead22

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/internal/locks.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const {
66
PromisePrototypeThen,
77
PromiseResolve,
88
SafePromisePrototypeFinally,
9+
StringPrototypeStartsWith,
910
Symbol,
1011
SymbolToStringTag,
1112
} = primordials;
@@ -159,7 +160,7 @@ class LockManager {
159160
signal.throwIfAborted();
160161
}
161162

162-
if (name.startsWith('-')) {
163+
if (StringPrototypeStartsWith(name, '-')) {
163164
// If name starts with U+002D HYPHEN-MINUS (-), then reject promise with a
164165
// "NotSupportedError" DOMException.
165166
throw lazyDOMException('Lock name may not start with hyphen',

0 commit comments

Comments
 (0)