summaryrefslogtreecommitdiff
path: root/libavformat/http.c
diff options
context:
space:
mode:
authorNil Admirari <nil-admirari@mailo.com>2022-06-20 13:30:00 +0300
committerMartin Storsjö <martin@martin.st>2022-06-21 13:27:46 +0300
commitc381f5412fe810bd8118123aed9bd4f76b75b59d (patch)
tree959b4b45a0e7aee5ee37cafec26474707053c252 /libavformat/http.c
parent13350e81fd43cbd1aa3bbb7ed567e7dc7dd2b7f5 (diff)
libavformat: Remove MAX_PATH limit and use UTF-8 version of getenv()
1. getenv() is replaced with getenv_utf8() across libavformat. 2. New versions of AviSynth+ are now called with UTF-8 filenames. 3. Old versions of AviSynth are still using ANSI strings, but MAX_PATH limit on filename is removed. Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavformat/http.c')
-rw-r--r--libavformat/http.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/libavformat/http.c b/libavformat/http.c
index c8f3f4b6a3..f80ea7bf35 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -29,6 +29,7 @@
#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/bprint.h"
+#include "libavutil/getenv_utf8.h"
#include "libavutil/opt.h"
#include "libavutil/time.h"
#include "libavutil/parseutils.h"
@@ -198,12 +199,13 @@ void ff_http_init_auth_state(URLContext *dest, const URLContext *src)
static int http_open_cnx_internal(URLContext *h, AVDictionary **options)
{
const char *path, *proxy_path, *lower_proto = "tcp", *local_path;
+ char *env_http_proxy, *env_no_proxy;
char *hashmark;
char hostname[1024], hoststr[1024], proto[10];
char auth[1024], proxyauth[1024] = "";
char path1[MAX_URL_SIZE], sanitized_path[MAX_URL_SIZE + 1];
char buf[1024], urlbuf[MAX_URL_SIZE];
- int port, use_proxy, err;
+ int port, use_proxy, err = 0;
HTTPContext *s = h->priv_data;
av_url_split(proto, sizeof(proto), auth, sizeof(auth),
@@ -211,9 +213,13 @@ static int http_open_cnx_internal(URLContext *h, AVDictionary **options)
path1, sizeof(path1), s->location);
ff_url_join(hoststr, sizeof(hoststr), NULL, NULL, hostname, port, NULL);
- proxy_path = s->http_proxy ? s->http_proxy : getenv("http_proxy");
- use_proxy = !ff_http_match_no_proxy(getenv("no_proxy"), hostname) &&
+ env_http_proxy = getenv_utf8("http_proxy");
+ proxy_path = s->http_proxy ? s->http_proxy : env_http_proxy;
+
+ env_no_proxy = getenv_utf8("no_proxy");
+ use_proxy = !ff_http_match_no_proxy(env_no_proxy, hostname) &&
proxy_path && av_strstart(proxy_path, "http://", NULL);
+ freeenv_utf8(env_no_proxy);
if (!strcmp(proto, "https")) {
lower_proto = "tls";
@@ -224,7 +230,7 @@ static int http_open_cnx_internal(URLContext *h, AVDictionary **options)
if (s->http_proxy) {
err = av_dict_set(options, "http_proxy", s->http_proxy, 0);
if (err < 0)
- return err;
+ goto end;
}
}
if (port < 0)
@@ -259,12 +265,12 @@ static int http_open_cnx_internal(URLContext *h, AVDictionary **options)
err = ffurl_open_whitelist(&s->hd, buf, AVIO_FLAG_READ_WRITE,
&h->interrupt_callback, options,
h->protocol_whitelist, h->protocol_blacklist, h);
- if (err < 0)
- return err;
}
- return http_connect(h, path, local_path, hoststr,
- auth, proxyauth);
+end:
+ freeenv_utf8(env_http_proxy);
+ return err < 0 ? err : http_connect(
+ h, path, local_path, hoststr, auth, proxyauth);
}
static int http_should_reconnect(HTTPContext *s, int err)