diff --git a/frigate/test/test_camera_pw.py b/frigate/test/test_camera_pw.py index dd72fcc7d..92aec48d8 100644 --- a/frigate/test/test_camera_pw.py +++ b/frigate/test/test_camera_pw.py @@ -36,3 +36,14 @@ class TestUserPassCleanup(unittest.TestCase): """Test that no change is made to path with no special characters.""" escaped = escape_special_characters(self.rtsp_with_pass) assert escaped == self.rtsp_with_pass + + +class TestUserPassMasking(unittest.TestCase): + def setUp(self) -> None: + self.rtsp_log_message = "Did you mean file:rtsp://user:password@192.168.1.3:554" + + def test_rtsp_in_log_message(self): + """Test that the rtsp url in a log message is espaced.""" + escaped = clean_camera_user_pass(self.rtsp_log_message) + print(f"The escaped is {escaped}") + assert escaped == "Did you mean file:rtsp://*:*@192.168.1.3:554" diff --git a/frigate/util.py b/frigate/util.py index 6a44811ba..a6fe4b294 100755 --- a/frigate/util.py +++ b/frigate/util.py @@ -722,7 +722,7 @@ def load_labels(path, encoding="utf-8"): def clean_camera_user_pass(line: str) -> str: """Removes user and password from line.""" - if line.startswith("rtsp://"): + if "rtsp://" in line: return re.sub(REGEX_RTSP_CAMERA_USER_PASS, "://*:*@", line) else: return re.sub(REGEX_HTTP_CAMERA_USER_PASS, "user=*&password=*", line)