Tiny Regex improvements

Summary: Recreation of D22118786, which was so old rebasing died on some lacking meta data. Lands https://github.com/facebook/flipper/pull/1256

Reviewed By: passy

Differential Revision: D24331424

fbshipit-source-id: 65fc5d8bf0242d4266e269716a319d71ce2e2826
This commit is contained in:
Michel Weststrate
2020-10-15 09:20:07 -07:00
committed by Facebook GitHub Bot
parent 6b7b1fab5c
commit 99757622a5
5 changed files with 10 additions and 16 deletions

View File

@@ -54,7 +54,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 = /^[\w._-]+$/;
const allowedAppNameRegex = /^[\w.-]+$/;
const logTag = 'CertificateProvider';
/*
* RFC2253 specifies the unamiguous x509 subject format.
@@ -395,11 +395,11 @@ export default class CertificateProvider {
.filter((d) => d.foundCsr !== null)
.map((d) => (d.foundCsr ? encodeURI(d.foundCsr) : 'null'));
console.error(`Looking for CSR (url encoded):
${encodeURI(this.santitizeString(csr))}
Found these:
${foundCsrs.join('\n\n')}`);
throw new Error(`No matching device found for app: ${appName}`);
}

View File

@@ -15,7 +15,7 @@
import {UnsupportedError} from './metrics';
import adbkit, {Client} from 'adbkit';
const allowedAppNameRegex = /^[\w._-]+$/;
const allowedAppNameRegex = /^[\w.-]+$/;
const appNotApplicationRegex = /not an application/;
const appNotDebuggableRegex = /debuggable/;
const operationNotPermittedRegex = /not permitted/;

View File

@@ -15,7 +15,7 @@ const isFBFile = (filePath: string) =>
filePath.includes(`${path.sep}fb${path.sep}`);
const requireFromFolder = (folder: string, path: string) =>
new RegExp(folder + '/[\\w.-_]+(.js)?$', 'g').test(path);
new RegExp(folder + '/[\\w.-]+(.js)?$', 'g').test(path);
module.exports = () => ({
name: 'replace-fb-stubs',

View File

@@ -321,7 +321,7 @@ export function parseCrashLog(
const regForName = /.*\n/;
const nameRegArr = regForName.exec(content);
let name = nameRegArr ? nameRegArr[0] : fallbackReason;
const regForCallStack = /\tat[\w\s\n.$&+,:;=?@#|'<>.^*()%!-]*$/;
const regForCallStack = /\tat[\w\s\n\.$&+,:;=?@#|'<>.^*()%!-]*$/;
const callStackArray = regForCallStack.exec(content);
const callStack = callStackArray ? callStackArray[0] : '';
let remainingString =
@@ -360,18 +360,12 @@ function truncate(baseString: string, numOfChars: number): string {
}
export function parsePath(content: string): Maybe<string> {
const regex = /Path: *[\w\-\/\.\t\ \_\%]*\n/;
const regex = /(?<=.*Path: *)[^\n]*/;
const arr = regex.exec(content);
if (!arr || arr.length <= 0) {
return null;
}
const pathString = arr[0];
const pathRegex = /[\w\-\/\.\t\ \_\%]*\n/;
const tmp = pathRegex.exec(pathString);
if (!tmp || tmp.length == 0) {
return null;
}
const path = tmp[0];
const path = arr[0];
return path.trim();
}

View File

@@ -12,7 +12,7 @@ import {colors, StackTrace} from 'flipper';
const FacebookLibraries = ['Facebook'];
const REGEX = /\d+\s+(?<library>(\s|\w|\.)+\w)\s+(?<address>0x\w+?)\s+(?<caller>.+) \+ (?<lineNumber>\d+)/;
const REGEX = /\d+\s+(?<library>[\s\w\.]+\w)\s+(?<address>0x\w+?)\s+(?<caller>.+) \+ (?<lineNumber>\d+)/;
function isSystemLibrary(libraryName: string | null | undefined): boolean {
return libraryName ? !FacebookLibraries.includes(libraryName) : false;