Skip to content

Android crash with RangeError: Maximum regex stack depth reached #29402

@alan7tw

Description

@alan7tw

Description

Hi there,

we're just trying add some regex to verify user input in the product,
but somehow it will crash directly by some specify user input on Android (iOS worked perfectly)
our regex is to verify user email format like following
/^(?=.{6,80}$)([A-Za-z0-9_\-]+[\.]?)*[A-Za-z0-9_\-]+@([A-Za-z0-9_\-]+)\.([A-Za-z0-9_\-]+[\.]?)*([A-Za-z0-9_\-]*[A-Za-z][A-Za-z])$/I;

and user input is 'aaaaaaaaaabbbbbbbbbbcccccccccc'

crash point is at Hermes, which show RangeError: Maximum regex stack depth reached, js engine: hermes
, but a strange thing is that , once enable debug mode from Developer Menu, it won't crash any more

React Native version:

System:
    OS: macOS Mojave 10.14.6
    CPU: (8) x64 Intel(R) Core(TM) i5-8279U CPU @ 2.40GHz
    Memory: 36.56 MB / 16.00 GB
    Shell: 5.8 - /usr/local/bin/zsh
  Binaries:
    Node: 14.4.0 - /usr/local/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 6.14.4 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.8.3 - /Users/alan_hsueh/.rvm/gems/ruby-2.7.0/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
    Android SDK: Not Found
  IDEs:
    Android Studio: 4.0 AI-193.6911.18.40.6514223
    Xcode: 11.3.1/11C504 - /usr/bin/xcodebuild
  Languages:
    Java: 12.0.1 - /usr/bin/javac
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.11.0 => 16.11.0
    react-native: 0.62.2 => 0.62.2
  npmGlobalPackages:
    *react-native*: Not Found

Steps To Reproduce

Provide a detailed list of steps that reproduce the issue.

  1. use <TextInput /> to input data aaaaaaaaaabbbbbbbbbbcccccccccc,
  2. bind Button submit, using regex check is email format with /^(?=.{6,80}$)([A-Za-z0-9_\-]+[\.]?)*[A-Za-z0-9_\-]+@([A-Za-z0-9_\-]+)\.([A-Za-z0-9_\-]+[\.]?)*([A-Za-z0-9_\-]*[A-Za-z][A-Za-z])$/i

Expected Results

should show it's not a valid input

Snack, code example, screenshot, or link to a repository:

let regEmail = /^(?=.{6,80}$)([A-Za-z0-9_\-]+[\.]?)*[A-Za-z0-9_\-]+@([A-Za-z0-9_\-]+)\.([A-Za-z0-9_\-]+[\.]?)*([A-Za-z0-9_\-]*[A-Za-z][A-Za-z])$/I;

if (regEmail.test(searchInputText) === false) {
  Toast.show(strings.alert.email_format_error, {
    duration: Toast.durations.LONG,
    position: Toast.positions.BOTTOM,
    shadow: true,
    animation: true,
    hideOnPress: true,
    delay: 0,
  });
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs: Triage 🔍Platform: AndroidAndroid applications.StaleThere has been a lack of activity on this issue and it may be closed soon.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions