From b23293abf963ca73096dea6021dceba6bd068f88 Mon Sep 17 00:00:00 2001
From: Armin Hasitzka <armin@grabyo.com>
Date: Thu, 10 Aug 2023 16:23:05 +0100
Subject: [PATCH] avformat/libsrt: Decode URL parameter strings

---
 libavformat/libsrt.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c
index cd8f5b1e7d..8986616334 100644
--- a/libavformat/libsrt.c
+++ b/libavformat/libsrt.c
@@ -32,6 +32,7 @@
 #include "network.h"
 #include "os_support.h"
 #include "url.h"
+#include "urldecode.h"
 
 /* This is for MPEG-TS and it's a default SRTO_PAYLOADSIZE for SRTT_LIVE (8 TS packets) */
 #ifndef SRT_LIVE_DEFAULT_PAYLOAD_SIZE
@@ -547,7 +548,7 @@ static int libsrt_open(URLContext *h, const char *uri, int flags)
         }
         if (av_find_info_tag(buf, sizeof(buf), "passphrase", p)) {
             av_freep(&s->passphrase);
-            s->passphrase = av_strndup(buf, strlen(buf));
+            s->passphrase = ff_urldecode(buf, 0);
         }
 #if SRT_VERSION_VALUE >= 0x010302
         if (av_find_info_tag(buf, sizeof(buf), "enforced_encryption", p)) {
@@ -632,7 +633,7 @@ static int libsrt_open(URLContext *h, const char *uri, int flags)
         }
         if (av_find_info_tag(buf, sizeof(buf), "streamid", p)) {
             av_freep(&s->streamid);
-            s->streamid = av_strdup(buf);
+            s->streamid = ff_urldecode(buf, 0);
             if (!s->streamid) {
                 ret = AVERROR(ENOMEM);
                 goto err;
@@ -640,7 +641,7 @@ static int libsrt_open(URLContext *h, const char *uri, int flags)
         }
         if (av_find_info_tag(buf, sizeof(buf), "smoother", p)) {
             av_freep(&s->smoother);
-            s->smoother = av_strdup(buf);
+            s->smoother = ff_urldecode(buf, 0);
             if(!s->smoother) {
                 ret = AVERROR(ENOMEM);
                 goto err;
-- 
2.41.0

