diff --git a/desktop/app/src/ui/components/searchable/Searchable.tsx b/desktop/app/src/ui/components/searchable/Searchable.tsx index 97fce108f..afa2d8db0 100644 --- a/desktop/app/src/ui/components/searchable/Searchable.tsx +++ b/desktop/app/src/ui/components/searchable/Searchable.tsx @@ -335,8 +335,8 @@ const Searchable = ( matchTags = debounce((searchTerm: string, matchEnd: boolean) => { const filterPattern = matchEnd - ? /([a-z][a-z0-9]*[!]?[:=][^\s]+)($|\s)/gi - : /([a-z][a-z0-9]*[!]?[:=][^\s]+)\s/gi; + ? /([a-z]\w*[!]?[:=]\S+)($|\s)/gi + : /([a-z]\w*[!]?[:=]\S+)\s/gi; const match = searchTerm.match(filterPattern); if (match && match.length > 0) { match.forEach((filter: string) => { diff --git a/desktop/app/src/utils/CertificateProvider.tsx b/desktop/app/src/utils/CertificateProvider.tsx index 6fe42cac9..f1a904197 100644 --- a/desktop/app/src/utils/CertificateProvider.tsx +++ b/desktop/app/src/utils/CertificateProvider.tsx @@ -46,7 +46,7 @@ const deviceClientCertFile = 'device.crt'; const caSubject = '/C=US/ST=CA/L=Menlo Park/O=Sonar/CN=SonarCA'; const serverSubject = '/C=US/ST=CA/L=Menlo Park/O=Sonar/CN=localhost'; const minCertExpiryWindowSeconds = 24 * 60 * 60; -const allowedAppNameRegex = /^[a-zA-Z0-9._\-]+$/; +const allowedAppNameRegex = /^[\w._-]+$/; const logTag = 'CertificateProvider'; /* * RFC2253 specifies the unamiguous x509 subject format. diff --git a/desktop/app/src/utils/androidContainerUtilityInternal.tsx b/desktop/app/src/utils/androidContainerUtilityInternal.tsx index 4e364aac8..c3c3e6b99 100644 --- a/desktop/app/src/utils/androidContainerUtilityInternal.tsx +++ b/desktop/app/src/utils/androidContainerUtilityInternal.tsx @@ -15,7 +15,7 @@ import {UnsupportedError} from './metrics'; import adbkit, {Client} from 'adbkit'; -const allowedAppNameRegex = /^[a-zA-Z0-9._\-]+$/; +const allowedAppNameRegex = /^[\w._-]+$/; const appNotApplicationRegex = /is not an application/; const appNotDebuggableRegex = /debuggable/; const operationNotPermittedRegex = /not permitted/; diff --git a/desktop/app/src/utils/environmentVariables.tsx b/desktop/app/src/utils/environmentVariables.tsx index 3f7622104..640413c7c 100644 --- a/desktop/app/src/utils/environmentVariables.tsx +++ b/desktop/app/src/utils/environmentVariables.tsx @@ -16,7 +16,7 @@ export function parseFlipperPorts( // Malformed numbers will get parsed to NaN which is not > 0 if ( ports.length === 2 && - components.every((x) => /^[0-9]+$/.test(x)) && + components.every((x) => /^\d+$/.test(x)) && ports.every((x) => x > 0) ) { return { diff --git a/desktop/babel-transformer/src/fb-stubs.ts b/desktop/babel-transformer/src/fb-stubs.ts index 525e63116..d3b87b518 100644 --- a/desktop/babel-transformer/src/fb-stubs.ts +++ b/desktop/babel-transformer/src/fb-stubs.ts @@ -15,7 +15,7 @@ const isFBFile = (filePath: string) => filePath.includes(`${path.sep}fb${path.sep}`); const requireFromFolder = (folder: string, path: string) => - new RegExp(folder + '/[A-Za-z0-9.-_]+(.js)?$', 'g').test(path); + new RegExp(folder + '/[\\w.-_]+(.js)?$', 'g').test(path); module.exports = () => ({ name: 'replace-fb-stubs', diff --git a/desktop/headless-tests/__tests__/headlessIntegrationTests.js b/desktop/headless-tests/__tests__/headlessIntegrationTests.js index c9260ab78..58cafbe46 100644 --- a/desktop/headless-tests/__tests__/headlessIntegrationTests.js +++ b/desktop/headless-tests/__tests__/headlessIntegrationTests.js @@ -123,7 +123,7 @@ test( 'Output includes fileVersion', () => { return runHeadless(basicArgs).then((result) => { - expect(result.output.fileVersion).toMatch(/[0-9]+\.[0-9]+\.[0-9]+/); + expect(result.output.fileVersion).toMatch(/\d+\.\d+\.\d+/); }); }, TEST_TIMEOUT_MS, diff --git a/desktop/plugins/crash_reporter/index.js b/desktop/plugins/crash_reporter/index.js index 145de8413..280dbf485 100644 --- a/desktop/plugins/crash_reporter/index.js +++ b/desktop/plugins/crash_reporter/index.js @@ -275,10 +275,10 @@ export function parseCrashLog( const fallbackReason = UNKNOWN_CRASH_REASON; switch (os) { case 'iOS': { - const regex = /Exception Type: *[\w]*/; + const regex = /Exception Type: *\w*/; const arr = regex.exec(content); const exceptionString = arr ? arr[0] : ''; - const exceptionRegex = /[\w]*$/; + const exceptionRegex = /\w*$/; const tmp = exceptionRegex.exec(exceptionString); const exception = tmp && tmp[0].length ? tmp[0] : fallbackReason; diff --git a/desktop/plugins/hermesdebuggerrn/ChromeDevTools.tsx b/desktop/plugins/hermesdebuggerrn/ChromeDevTools.tsx index bc4a040f5..37db35061 100644 --- a/desktop/plugins/hermesdebuggerrn/ChromeDevTools.tsx +++ b/desktop/plugins/hermesdebuggerrn/ChromeDevTools.tsx @@ -12,10 +12,7 @@ import React from 'react'; import electron from 'electron'; const devToolsNodeId = (url: string) => - `hermes-chromedevtools-out-of-react-node-${url.replace( - /[^a-zA-Z0-9]+/g, - '-', - )}`; + `hermes-chromedevtools-out-of-react-node-${url.replace(/\W+/g, '-')}`; // TODO: build abstractionf or this: T62306732 const TARGET_CONTAINER_ID = 'flipper-out-of-contents-container'; // should be a hook in the future diff --git a/desktop/plugins/kaios-ram/index.tsx b/desktop/plugins/kaios-ram/index.tsx index be14f8a29..67d1a6b11 100644 --- a/desktop/plugins/kaios-ram/index.tsx +++ b/desktop/plugins/kaios-ram/index.tsx @@ -167,7 +167,7 @@ export default class KaiOSGraphs extends FlipperDevicePlugin { ) { continue; } - if (fields[1].match(/[^0-9]+/)) { + if (fields[1].match(/\D+/)) { // TODO: probably implement this through something other than b2g throw new Error('Support for names with spaces is not implemented'); } diff --git a/desktop/plugins/sections/StackTrace.js b/desktop/plugins/sections/StackTrace.js index fa079cad7..1dd0c54a7 100644 --- a/desktop/plugins/sections/StackTrace.js +++ b/desktop/plugins/sections/StackTrace.js @@ -12,9 +12,7 @@ import {colors, StackTrace} from 'flipper'; const FacebookLibraries = ['Facebook']; -const REGEX = new RegExp( - '(?[A-Za-z0-9]*) *(?
0x[A-Za-z0-9]*) (?(.*)) \\+ (?[0-9]*)', -); +const REGEX = /(?\w*) *(?
0x\w*) (?(.*)) \\+ (?\d*)/; function isSystemLibrary(libraryName: ?string): boolean { return !FacebookLibraries.includes(libraryName);