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>
This commit is contained in:
Nil Admirari
2022-06-20 13:30:00 +03:00
committed by Martin Storsjö
parent 13350e81fd
commit c381f5412f
4 changed files with 74 additions and 34 deletions

View File

@@ -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)