[ipcamera] Added URL encoding fix for passwords that contains special characters. (#13035)

* Added URL encoding fix for passwords that contains special characters.
* Simplified as proposed.

Signed-off-by: Thomas Burri <th@thonjato.ch>
This commit is contained in:
tb4jc 2022-06-30 08:27:40 +02:00 committed by GitHub
parent 5f115295a4
commit f203b3f202
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -18,6 +18,8 @@ import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@ -56,12 +58,13 @@ public class Ffmpeg {
public Ffmpeg(IpCameraHandler handle, FFmpegFormat format, String ffmpegLocation, String inputArguments,
String input, String outArguments, String output, String username, String password) {
this.format = format;
this.password = password;
this.password = URLEncoder.encode(password, StandardCharsets.UTF_8);
ipCameraHandler = handle;
String altInput = input;
// Input can be snapshots not just rtsp or http
if (!password.isEmpty() && !input.contains("@") && input.contains("rtsp")) {
String credentials = username + ":" + password + "@";
String credentials = username + ":" + this.password + "@";
// will not work for https: but currently binding does not use https
altInput = input.substring(0, 7) + credentials + input.substring(7);
}