Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"total" validation for NaN format #171

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jacob-rogers
Copy link

Found some cases when total attribute may not be defined as Number/String/undefined, but could be a NaN format implicitly or not.

For example, my app using node-progress lib and has no request validation for incoming data Content-Length attribute.
But it was actually passed into const total = parseInt(contentLength, 10) as undefined.
And total has taken NaN.

Eventually, it throws the errors like described in #166:

complete = Array(Math.max(0, completeLength + 1)).join(this.chars.complete);
             ^

RangeError: Invalid array length
    at ProgressBar.render (.../node_modules/progress/lib/node-progress.js:155:14)
    at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)

where completeLength takes NaN from total.

Perhaps it could be more convenient to track if we missed a real total value transmitted if it throws when constructor of ProgressBar called.

I will be grateful if someone responds to this. Thanks.

@alwxkxk alwxkxk mentioned this pull request Apr 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant