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

lib/helpers: fixed is_valid_packet() #382

Merged
merged 1 commit into from Feb 11, 2014
Merged

Conversation

SaveTheRbtz
Copy link
Contributor

This commit introduces following changes:

  • Be liberal in what you recieve - do not rely on regexps for packet
    parsing but instead accept anything that can be parsed by JavaScript
    as a number e.g: +1e-17, -0511, 0xDEADbeef, etc
  • Accept both positive and negative counters with explicit / implicit
    sign
  • Provides more strict error checking then regexp, for example
    following strings match previously used '([-+\d.]+' regexp:
    .
    .123.
    .-+\0+-.1-

Also while here added more tests.

Closes: #350 #357 #363

Signed-off-by: Alexey Ivanov SaveTheRbtz@GMail.com

This commit introduces following changes:
 * Be liberal in what you recieve - do not rely on regexps for packet
   parsing but instead accept anything that can be parsed by JavaScript
   as a number e.g: +1e-17, -0511, 0xDEADbeef, etc
 * Accept both positive and negative counters with explicit / implicit
   sign
 * Provides more strict error checking then regexp, for example
   following strings match previously used '([\-\+\d\.]+' regexp:
   .
   .123.
   .\-+\0\+-.1-

Also while here added more tests.

Closes: statsd#350 statsd#357

Signed-off-by: Alexey Ivanov <SaveTheRbtz@GMail.com>
@mrtazz
Copy link
Member

mrtazz commented Feb 11, 2014

Looks good, thanks for submitting this!

mrtazz added a commit that referenced this pull request Feb 11, 2014
lib/helpers: fixed is_valid_packet()
@mrtazz mrtazz merged commit 5b90071 into statsd:master Feb 11, 2014
case 'g':
return isNumber(fields[0]);
case 'ms':
return isNumber(fields[0]) && Number(fields[0]) > 0;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be Number(fields[0]) >= 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed it should, if you have time you can patch it and add test for that particular case. If not, I'll probably do it myself within a week or so.

SaveTheRbtz pushed a commit to SaveTheRbtz/statsd that referenced this pull request Feb 23, 2014
SaveTheRbtz pushed a commit to SaveTheRbtz/statsd that referenced this pull request Feb 23, 2014
This was referenced Apr 14, 2014
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.

None yet

3 participants