1
0
mirror of https://github.com/mpv-player/mpv synced 2025-01-03 13:32:16 +00:00

cookies: don't read cookie files from ancient browsers

Remove the code that attempted to read cookie files from well-known
browser locations. This code was written for ancient browsers, and only
knew about Mozilla and Netscape. While it's possible that these browsers
are still alive and still use the same config locations and cookie file
formats, the only Mozilla-based browser that still matters is Firefox.
Firefox uses a sqlite database for cookies, located in a slightly
different config path.

Just remove this code.
This commit is contained in:
wm4 2012-11-15 17:53:12 +01:00
parent db45c8771a
commit b4b86e9286
2 changed files with 4 additions and 44 deletions

View File

@ -435,8 +435,7 @@
--cookies-file=<filename>
(network only)
Read HTTP cookies from <filename> (default: ``~/.mozilla/`` and
``~/.netscape/``) and skip reading from default locations. The file is
Read HTTP cookies from <filename>. The file is
assumed to be in Netscape format.
--correct-pts, --no-correct-pts

View File

@ -181,52 +181,13 @@ static struct cookie_list_type *load_cookies_from(const char *filename,
return list;
}
/* Attempt to load cookies.txt from various locations. Returns a pointer to the linked list contain the cookies. */
/* Attempt to load cookies.txt. Returns a pointer to the linked list contain the cookies. */
static struct cookie_list_type *load_cookies(void)
{
DIR *dir;
struct dirent *ent;
struct cookie_list_type *list = NULL;
char *buf;
char *homedir;
if (cookies_file)
return load_cookies_from(cookies_file, list);
return load_cookies_from(cookies_file, NULL);
homedir = getenv("HOME");
if (!homedir)
return list;
buf = malloc(strlen(homedir) + sizeof("/.mozilla/default") + 1);
sprintf(buf, "%s/.mozilla/default", homedir);
dir = opendir(buf);
free(buf);
if (dir) {
while ((ent = readdir(dir)) != NULL) {
if ((ent->d_name)[0] != '.') {
const char *home = getenv("HOME");
unsigned len = strlen(home) +
sizeof("/.mozilla/default/") +
strlen(ent->d_name) + sizeof("cookies.txt") + 1;
buf = malloc(len);
snprintf(buf, len, "%s/.mozilla/default/%s/cookies.txt",
home, ent->d_name);
list = load_cookies_from(buf, list);
free(buf);
}
}
closedir(dir);
}
buf = malloc(strlen(homedir) + sizeof("/.netscape/cookies.txt") + 1);
sprintf(buf, "%s/.netscape/cookies.txt", homedir);
list = load_cookies_from(buf, list);
free(buf);
return list;
return NULL;
}
/* Take an HTTP_header_t, and insert the correct headers. The cookie files are read if necessary. */