mirror of
https://github.com/ZoneMinder/zoneminder.git
synced 2026-12-01 04:38:35 -05:00
fix: onvif probe stream URL has no empty userinfo and encodes the username refs #6602
This commit is contained in:
1 parent
e8b3b1b743
commit
c44690a91b
2 files changed
+23
-1
No files matched your search
@@ -61,5 +61,22 @@ namespace {
|
||||
eval($m[0]);
|
||||
check("one detected entry keeps the choose text for $v", $$v[0], 'Choose');
|
||||
}
|
||||
|
||||
// probeProfiles() puts the credentials into the stream URL: none when there
|
||||
// are none, and a username with reserved characters is encoded.
|
||||
if (!preg_match('/^function probeProfiles\(.*?^\} \/\/ end function probeProfiles/ms', $op, $m)) {
|
||||
echo "FAIL - probeProfiles() not found\n";
|
||||
exit(1);
|
||||
}
|
||||
function execONVIF($cmd, $log_cmd = null) {
|
||||
return array('Profile_1, main, H264, 1920, 1080, 25, RTP-Unicast, rtsp://10.0.0.5:554/stream1');
|
||||
}
|
||||
eval($m[0]);
|
||||
$r = probeProfiles('http://10.0.0.5/onvif/device_service', '1', '', '');
|
||||
check('no credentials leave the stream URL without userinfo', $r[0]['Path'], 'rtsp://10.0.0.5:554/stream1');
|
||||
$r = probeProfiles('http://10.0.0.5/onvif/device_service', '1', 'ad@min', 'pw');
|
||||
check('username is URL encoded', $r[0]['Path'], 'rtsp://ad%40min:pw@10.0.0.5:554/stream1');
|
||||
$r = probeProfiles('http://10.0.0.5/onvif/device_service', '1', 'admin', '');
|
||||
check('username alone keeps the colon', $r[0]['Path'], 'rtsp://admin:@10.0.0.5:554/stream1');
|
||||
exit($failures ? 1 : 0);
|
||||
}
|
||||
@@ -125,7 +125,12 @@ function probeProfiles($device_ep, $soapversion, $username, $password) {
|
||||
// decoded, which is also quite appropriate. However, that
|
||||
// also applies to the password sub-field of the Path
|
||||
// attribute. So, we must double encode the embedded password.
|
||||
$stream_uri = $tokens[1].$username.':'.urlencode(urlencode($password)).'@'.$tokens[2];
|
||||
// Without credentials there is no userinfo at all: rtsp://:@host is not a valid URL.
|
||||
$userinfo = '';
|
||||
if ((string)$username !== '' || (string)$password !== '') {
|
||||
$userinfo = rawurlencode((string)$username).':'.urlencode(urlencode((string)$password)).'@';
|
||||
}
|
||||
$stream_uri = $tokens[1].$userinfo.$tokens[2];
|
||||
}
|
||||
ZM\Debug(print_r($matches, true));
|
||||
|
||||
|
||||
Reference in new issue
Block a user