From f203b3f2021cc60abe5031290a77c2cca8177224 Mon Sep 17 00:00:00 2001 From: tb4jc Date: Thu, 30 Jun 2022 08:27:40 +0200 Subject: [PATCH] [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 --- .../java/org/openhab/binding/ipcamera/internal/Ffmpeg.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bundles/org.openhab.binding.ipcamera/src/main/java/org/openhab/binding/ipcamera/internal/Ffmpeg.java b/bundles/org.openhab.binding.ipcamera/src/main/java/org/openhab/binding/ipcamera/internal/Ffmpeg.java index 5df1abb27..2c4098273 100644 --- a/bundles/org.openhab.binding.ipcamera/src/main/java/org/openhab/binding/ipcamera/internal/Ffmpeg.java +++ b/bundles/org.openhab.binding.ipcamera/src/main/java/org/openhab/binding/ipcamera/internal/Ffmpeg.java @@ -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); }