Skip to content

Fix strlen crashing when argument is not string#158

Merged
chrean merged 1 commit intoAutomattic:masterfrom
dreinert1994:master
Nov 23, 2021
Merged

Fix strlen crashing when argument is not string#158
chrean merged 1 commit intoAutomattic:masterfrom
dreinert1994:master

Conversation

@dreinert1994
Copy link
Copy Markdown

@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