generate-password icon indicating copy to clipboard operation
generate-password copied to clipboard

[Bug] infinite loop when excluding all symbols and strictly requiring symbols

Open dillonstreator opened this issue 4 years ago • 3 comments

generate-password v1.5.1 currently has a bug which results in a max callstack size exceeded

The bug occurs when strictly requiring and then excluding those characters.

i.e.

import generator from 'generate-password';

generator.generate({
  strict: true,
  numbers: true,
  exclude: "1234567890",
});

Could we instead throw an error if the configuration is not possible?

dillonstreator avatar Jul 06 '20 18:07 dillonstreator

The same error happens with the following options: { length: 6, numbers: true, strict: true, symbols: true, exclude: '' }

nemethyd avatar Jul 01 '21 04:07 nemethyd

I also got Maximum call stack size exceeded with the following configuration:

const symbols = '$*.[]{}()?\\-"!@#%&/\\,><^\':;|_~`+=';

{
  length: 32,
  lowercase: true,
  numbers: true,
  strict: true,
  symbols,
  uppercase: true,
}

I fixed it by escaping ] to be \\] so the full string of symbols will be:

$*.[\\]{}()?\\-"!@#%&/\\,><^\':;|_~\`+=

It seems like any misconfiguration throws this error.

khause avatar Mar 02 '22 18:03 khause

Thanks:

From: Kingsley Hause @.> Sent: Wednesday, March 2, 2022 7:54 PM To: brendanashworth/generate-password @.> Cc: Dániel Némethy @.>; Comment @.> Subject: Re: [brendanashworth/generate-password] [Bug] infinite loop when excluding all symbols and strictly requiring symbols (#48)

I also got Maximum call stack size exceeded with the following configuration:

const symbols = '$*.[]{}()?\-"!@#%&/\,><^':;|_~`+=';

{

length: 32,

lowercase: true,

numbers: true,

strict: true,

symbols,

uppercase: true,

}

I fixed it by escaping ] to be \] so the full string of symbols will be:

$*.[\]{}()?\-"!@#%&/\,><^':;|_~`+=

It seems like any misconfiguration throws this error.

— Reply to this email directly, view it on GitHubhttps://github.com/brendanashworth/generate-password/issues/48#issuecomment-1057269720, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADDDYKCVLNLNCQQQQMOHBEDU562LNANCNFSM4OR4AOGQ. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you commented.Message ID: @.@.>>

nemethyd avatar Mar 03 '22 05:03 nemethyd