From 95eb1e2a283ef29cf887a89f9e5d0e7a85b756c8 Mon Sep 17 00:00:00 2001 From: Jamin Hitchcock Date: Fri, 10 Feb 2023 08:57:26 -0600 Subject: [PATCH] URL encode username and password in RTSP URLs --- src/amcrest/special.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/amcrest/special.py b/src/amcrest/special.py index 98b53a5..de6f8b3 100644 --- a/src/amcrest/special.py +++ b/src/amcrest/special.py @@ -10,6 +10,7 @@ # vim:sw=4:ts=4:et import logging import shutil +import urllib.parse from typing import Optional from urllib3.exceptions import HTTPError @@ -95,7 +96,10 @@ def _build_rtsp_url( else: port = ":{}".format(port_num) - return f"rtsp://{self._user}:{self._password}@{self._host}{port}/{cmd}" + username = urllib.parse.quote(self._user, safe='') + password = urllib.parse.quote(self._password, safe='') + + return f"rtsp://{username}:{password}@{self._host}{port}/{cmd}" # pylint: disable=pointless-string-statement """