]> git.basschouten.com Git - openhab-addons.git/commitdiff
[ipcamera] Added URL encoding fix for passwords that contains special characters...
authortb4jc <tb4jc@users.noreply.github.com>
Thu, 30 Jun 2022 06:27:40 +0000 (08:27 +0200)
committerGitHub <noreply@github.com>
Thu, 30 Jun 2022 06:27:40 +0000 (08:27 +0200)
* Added URL encoding fix for passwords that contains special characters.
* Simplified as proposed.

Signed-off-by: Thomas Burri <th@thonjato.ch>
bundles/org.openhab.binding.ipcamera/src/main/java/org/openhab/binding/ipcamera/internal/Ffmpeg.java

index 5df1abb2761942f6a8834d3833b5974f24891872..2c409827324e55b995ed2f1f60317aadef8e29be 100644 (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);
         }