From b50868bf3015176526d78c045c9c1303f395d63b Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Wed, 24 May 2023 01:58:01 +0200 Subject: [PATCH] treewide: make regex patterns raw strings This is necessary for escape sequences to be properly recognized. --- frigate/const.py | 6 +++--- frigate/util.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/frigate/const.py b/frigate/const.py index cfcdc2a53..df5098853 100644 --- a/frigate/const.py +++ b/frigate/const.py @@ -13,9 +13,9 @@ BTBN_PATH = "/usr/lib/btbn-ffmpeg" # Regex Consts -REGEX_CAMERA_NAME = "^[a-zA-Z0-9_-]+$" -REGEX_RTSP_CAMERA_USER_PASS = ":\/\/[a-zA-Z0-9_-]+:[\S]+@" -REGEX_HTTP_CAMERA_USER_PASS = "user=[a-zA-Z0-9_-]+&password=[\S]+" +REGEX_CAMERA_NAME = r"^[a-zA-Z0-9_-]+$" +REGEX_RTSP_CAMERA_USER_PASS = r":\/\/[a-zA-Z0-9_-]+:[\S]+@" +REGEX_HTTP_CAMERA_USER_PASS = r"user=[a-zA-Z0-9_-]+&password=[\S]+" # Known Driver Names diff --git a/frigate/util.py b/frigate/util.py index 056c5eb1b..e624e877a 100755 --- a/frigate/util.py +++ b/frigate/util.py @@ -863,7 +863,7 @@ def get_bandwidth_stats() -> dict[str, dict]: stats = list(filter(lambda a: a != "", line.strip().split("\t"))) try: if re.search( - "(^ffmpeg|\/go2rtc|frigate\.detector\.[a-z]+)/([0-9]+)/", stats[0] + r"(^ffmpeg|\/go2rtc|frigate\.detector\.[a-z]+)/([0-9]+)/", stats[0] ): process = stats[0].split("/") usages[process[len(process) - 2]] = { @@ -930,7 +930,7 @@ def get_intel_gpu_stats() -> dict[str, str]: # render is used for qsv render = [] - for result in re.findall('"Render/3D/0":{[a-z":\d.,%]+}', reading): + for result in re.findall(r'"Render/3D/0":{[a-z":\d.,%]+}', reading): packet = json.loads(result[14:]) single = packet.get("busy", 0.0) render.append(float(single))