From 5066b2be80dd2bdb185a14c235a0b4ac543c09ad Mon Sep 17 00:00:00 2001 From: Eric Han Date: Fri, 28 Jul 2023 10:22:01 +0800 Subject: [PATCH] Fix: regex execution Maximum regex stack depth reached error --- package-lock.json | 12 ++++++------ package.json | 2 +- src/libs/Url.js | 10 +++++++++- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 95b1428a4ace..e44c7a65d99f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -40,7 +40,7 @@ "babel-polyfill": "^6.26.0", "dom-serializer": "^0.2.2", "domhandler": "^4.3.0", - "expensify-common": "git+ssh://git@github.com/Expensify/expensify-common.git#98d8fea356f114f8b5b0cea889a41b355e5daf58", + "expensify-common": "git+ssh://git@github.com/Expensify/expensify-common.git#9940dd127c2d44809c98ee628a8057f08c93bfc9", "fbjs": "^3.0.2", "htmlparser2": "^7.2.0", "jest-when": "^3.5.2", @@ -24380,8 +24380,8 @@ }, "node_modules/expensify-common": { "version": "1.0.0", - "resolved": "git+ssh://git@github.com/Expensify/expensify-common.git#98d8fea356f114f8b5b0cea889a41b355e5daf58", - "integrity": "sha512-gs3xWgNCjLJsgB9j/oIZaGxQXNM61MapC0eGqtFHgKEwHy6rt08zyZq5CZCow4PVTtF8xgWgkpVifti2dr43cQ==", + "resolved": "git+ssh://git@github.com/Expensify/expensify-common.git#9940dd127c2d44809c98ee628a8057f08c93bfc9", + "integrity": "sha512-de8+wMI7IwklsgpYW7rfLCUVOZ3yy4I2iPKg9X/BjvwQGrUuGZmpPJfNfWkkO14SqdZwBZiroKhii1kymxjiWg==", "license": "MIT", "dependencies": { "classnames": "2.3.1", @@ -60168,9 +60168,9 @@ } }, "expensify-common": { - "version": "git+ssh://git@github.com/Expensify/expensify-common.git#98d8fea356f114f8b5b0cea889a41b355e5daf58", - "integrity": "sha512-gs3xWgNCjLJsgB9j/oIZaGxQXNM61MapC0eGqtFHgKEwHy6rt08zyZq5CZCow4PVTtF8xgWgkpVifti2dr43cQ==", - "from": "expensify-common@git+ssh://git@github.com/Expensify/expensify-common.git#98d8fea356f114f8b5b0cea889a41b355e5daf58", + "version": "git+ssh://git@github.com/Expensify/expensify-common.git#9940dd127c2d44809c98ee628a8057f08c93bfc9", + "integrity": "sha512-de8+wMI7IwklsgpYW7rfLCUVOZ3yy4I2iPKg9X/BjvwQGrUuGZmpPJfNfWkkO14SqdZwBZiroKhii1kymxjiWg==", + "from": "expensify-common@git+ssh://git@github.com/Expensify/expensify-common.git#9940dd127c2d44809c98ee628a8057f08c93bfc9", "requires": { "classnames": "2.3.1", "clipboard": "2.0.4", diff --git a/package.json b/package.json index e0b0cc035796..e60071454c32 100644 --- a/package.json +++ b/package.json @@ -78,7 +78,7 @@ "babel-polyfill": "^6.26.0", "dom-serializer": "^0.2.2", "domhandler": "^4.3.0", - "expensify-common": "git+ssh://git@github.com/Expensify/expensify-common.git#98d8fea356f114f8b5b0cea889a41b355e5daf58", + "expensify-common": "git+ssh://git@github.com/Expensify/expensify-common.git#9940dd127c2d44809c98ee628a8057f08c93bfc9", "fbjs": "^3.0.2", "htmlparser2": "^7.2.0", "jest-when": "^3.5.2", diff --git a/src/libs/Url.js b/src/libs/Url.js index b2c1c70edc16..7e7c230de95f 100644 --- a/src/libs/Url.js +++ b/src/libs/Url.js @@ -19,7 +19,15 @@ function addTrailingForwardSlash(url) { */ function getURLObject(href) { const urlRegex = new RegExp(URL_WEBSITE_REGEX, 'gi'); - const match = urlRegex.exec(href); + let match; + try { + if (!href.startsWith('mailto:')) { + match = urlRegex.exec(href); + } + } catch (e) { + // eslint-disable-next-line no-console + console.warn('Error parsing url in Url.getURLObject', {error: e}); + } if (!match) { return { href: undefined,