mirror of
https://github.com/BetterCorp/BetterFrame.git
synced 2026-05-26 16:56:33 +00:00
fix: decode XML entities in ONVIF RTSP URIs
ONVIF returns XML with & in URIs. GStreamer rtspsrc cant parse these. Now decoded before storing in camera_streams. Fixes RTSP Unauthorized for ONVIF-discovered cameras with query params. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
2a21ababc0
commit
b6e929d2ad
1 changed files with 6 additions and 4 deletions
|
|
@ -112,15 +112,17 @@ async function uniqueCameraName(deps: AdminDeps, rawName: string): Promise<strin
|
||||||
}
|
}
|
||||||
|
|
||||||
function rtspWithCredentials(raw: string, username: string, password: string): string {
|
function rtspWithCredentials(raw: string, username: string, password: string): string {
|
||||||
if (!username) return raw;
|
// ONVIF returns XML — URIs may contain & instead of &
|
||||||
|
let clean = raw.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
||||||
|
if (!username) return clean;
|
||||||
try {
|
try {
|
||||||
const url = new URL(raw);
|
const url = new URL(clean);
|
||||||
if (url.protocol !== "rtsp:" || url.username) return raw;
|
if (url.protocol !== "rtsp:" || url.username) return clean;
|
||||||
url.username = username;
|
url.username = username;
|
||||||
url.password = password;
|
url.password = password;
|
||||||
return url.toString();
|
return url.toString();
|
||||||
} catch {
|
} catch {
|
||||||
return raw;
|
return clean;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue