Skip to content

Commit 12b6c56

Browse files
author
surbhi
committed
Verify scheme and suppress B310
1 parent 0be9bd2 commit 12b6c56

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/upnp.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,10 @@ def __init__(self, ssdpResponse, address):
109109
logger.error("UPnP: missing location header")
110110

111111
# get the profile xml file and read it into a variable
112-
directory = urlopen(header['location']).read()
112+
parsed_url = urlparse(header['location'])
113+
if parsed_url.scheme not in ['http', 'https']:
114+
raise UPnPError("Unsupported URL scheme: %s" % parsed_url.scheme)
115+
directory = urlopen(header['location']).read() # nosec B310
113116

114117
# create a DOM object that represents the `directory` document
115118
dom = parseString(directory)

0 commit comments

Comments
 (0)