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

Fix strlen crashing when argument is not string #158

Merged
merged 1 commit into from
Nov 23, 2021

Conversation

dreinert1994
Copy link

@dreinert1994 dreinert1994 commented Nov 18, 2021

Description

0.3.7 introduce a breaking change where the strlen util function can no longer handle non-string arguments. It attempts to pass the argument to stripAnsi regardless which returns null. It then attempts .split, which crashes when str is not a string. This should ensure that does not happen by always guaranteeing the argument to stripAnsi is a string. This will resolve #152 and #157

Checklist

Please make sure the items below have been covered before requesting a review:

  • This change works and has been tested locally (or has an appropriate fallback).
  • This change has relevant unit tests.
  • This change has relevant documentation additions / updates (if applicable).

Deploy Notes

Notes regarding deployment of this PR, if any.

Steps to Test or Reproduce

Added unit tests to confirm the strlen function can handle both string and non-string arguments, which was causing the error previously

Example:

  1. Pull down PR.
  2. Run tests
  3. Verify they all pass

@chrean chrean merged commit b5385ca into Automattic:master Nov 23, 2021
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.

0.3.7 is broken
2 participants