Skip to content

Commit

Permalink
prevent extraordinary long inputs (@evilpacket)
Browse files Browse the repository at this point in the history
  • Loading branch information
rauchg committed Apr 20, 2015
1 parent 6cd2d0b commit 48701f0
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ module.exports = function(val, options){
*/

function parse(str) {
str = '' + str;

This comment has been minimized.

Copy link
@macalinao

macalinao Nov 6, 2015

What does this do?

This comment has been minimized.

Copy link
@evilpacket

evilpacket via email Nov 6, 2015

This comment has been minimized.

Copy link
@macalinao

macalinao Nov 6, 2015

No, I mean what does line 41 do?

This comment has been minimized.

Copy link
@evilpacket

evilpacket Nov 6, 2015

Force type to string

This comment has been minimized.

Copy link
@macalinao

macalinao via email Nov 6, 2015

if (str.length > 10000) return;
var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(str);
if (!match) return;
var n = parseFloat(match[1]);
Expand Down

0 comments on commit 48701f0

Please sign in to comment.