Skip to content

Commit 2e89af8

Browse files
Merge pull request #224 from jaminh/url_encode
URL encode username and password in RTSP URLs
2 parents 9cced67 + 95eb1e2 commit 2e89af8

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/amcrest/special.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
# vim:sw=4:ts=4:et
1111
import logging
1212
import shutil
13+
import urllib.parse
1314
from typing import Optional
1415

1516
from urllib3.exceptions import HTTPError
@@ -95,7 +96,10 @@ def _build_rtsp_url(
9596
else:
9697
port = ":{}".format(port_num)
9798

98-
return f"rtsp://{self._user}:{self._password}@{self._host}{port}/{cmd}"
99+
username = urllib.parse.quote(self._user, safe='')
100+
password = urllib.parse.quote(self._password, safe='')
101+
102+
return f"rtsp://{username}:{password}@{self._host}{port}/{cmd}"
99103

100104
# pylint: disable=pointless-string-statement
101105
"""

0 commit comments

Comments
 (0)