Skip to content

Cannot call string methods on empty string #1628

@borboss366

Description

@borboss366

If you have a string, and try to use some of the default string methods (like toUpperCase, toLowerCase, etc).
If the string is '' (empty) calling these methods will fail with error 'No access to method', because of the check in isSafeMethod function.

  if (!object || typeof object[method] !== 'function') {
    return false;
  }

!'' is always true. But '' is a legit string.
!object should be replaced with condition !== null && !== undefined

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions