You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On yargs@16.2.0 I discovered a bug causing the application to crash unexpectedly if one of the values in the arguments array provided to the yargs function is exactly ---- (i.e., 4 hyphens). As far as I can tell any other number of hyphens works fine, I did not test any other version of yargs. The error produced by this input can be found below and it is thrown (if I'm not mistaken) by this snippet of code:
I'm not exactly sure what goes wrong but it seems to me that argv['--'] is internally used for something, and by using the argument value ---- this value is changed unexpectedly resulting in the error.
.../node_modules/yargs/build/index.cjs:2794
argv._.push.apply(argv._, argv['--']);
^
TypeError: CreateListFromArrayLike called on non-object
at Object.Yargs.self._copyDoubleDash (.../node_modules/yargs/build/index.cjs:2794:21)
at Object.Yargs.self._postProcess (.../node_modules/yargs/build/index.cjs:2782:25)
at Object.parseArgs [as _parseArgs] (.../node_modules/yargs/build/index.cjs:2774:21)
at Object.get [as argv] (.../node_modules/yargs/build/index.cjs:2651:25)
at Object.<anonymous> (.../src/index.ts:41:5)
at Module._compile (internal/modules/cjs/loader.js:1157:30)
at Module.m._compile (/home/eric/.nvm/versions/node/v12.16.0/lib/node_modules/ts-node/src/index.ts:1056:23)
at Module._extensions..js (internal/modules/cjs/loader.js:1177:10)
at Object.require.extensions.<computed> [as .ts] (/home/eric/.nvm/versions/node/v12.16.0/lib/node_modules/ts-node/src/index.ts:1059:12)
at Module.load (internal/modules/cjs/loader.js:1001:32)
EDIT: it seems that appending whitespace characters (e.g. \r or \n) or = and than other non-space character to ---- will still result in the same error.
The text was updated successfully, but these errors were encountered:
One minor thing: it seems the issue persists if the ---- is followed by a \n or \r, likely due to the details the regular expression you used to fix the initial issue. I'm not sure if you consider this a problem. But if you want to fix it, assuming args in that snippet is a trimmed string, the regular expression /---+(\s+|=|$)/ should prevent the issue from showing up due to \n or \r (or other whitespace characters) as well.
On
yargs@16.2.0
I discovered a bug causing the application to crash unexpectedly if one of the values in the arguments array provided to theyargs
function is exactly----
(i.e., 4 hyphens). As far as I can tell any other number of hyphens works fine, I did not test any other version of yargs. The error produced by this input can be found below and it is thrown (if I'm not mistaken) by this snippet of code:yargs/lib/yargs-factory.ts
Lines 1757 to 1760 in 31765cb
I'm not exactly sure what goes wrong but it seems to me that
argv['--']
is internally used for something, and by using the argument value----
this value is changed unexpectedly resulting in the error.EDIT: it seems that appending whitespace characters (e.g.
\r
or\n
) or=
and than other non-space character to----
will still result in the same error.The text was updated successfully, but these errors were encountered: