mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
lib: refactor to avoid unsafe regex primordials
PR-URL: https://github.com/nodejs/node/pull/43475 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
This commit is contained in:
parent
411fb21723
commit
a055337a02
39 changed files with 206 additions and 208 deletions
|
@ -9,7 +9,7 @@ const {
|
|||
NumberMAX_SAFE_INTEGER,
|
||||
NumberMIN_SAFE_INTEGER,
|
||||
NumberParseInt,
|
||||
RegExpPrototypeTest,
|
||||
RegExpPrototypeExec,
|
||||
String,
|
||||
StringPrototypeToUpperCase,
|
||||
StringPrototypeTrim,
|
||||
|
@ -58,7 +58,7 @@ const modeDesc = 'must be a 32-bit unsigned integer or an octal string';
|
|||
function parseFileMode(value, name, def) {
|
||||
value ??= def;
|
||||
if (typeof value === 'string') {
|
||||
if (!RegExpPrototypeTest(octalReg, value)) {
|
||||
if (RegExpPrototypeExec(octalReg, value) === null) {
|
||||
throw new ERR_INVALID_ARG_VALUE(name, value, modeDesc);
|
||||
}
|
||||
value = NumberParseInt(value, 8);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue