1
0
mirror of https://github.com/rkd77/elinks.git synced 2025-02-02 15:09:23 -05:00

bug 638: Proper handling of mailcap.

Mailcap handlers work both for (master/slave and XWindow/console)
terminals. This is done by setting and unsetting the DISPLAY
environment variable.
This commit is contained in:
Witold Filipczyk 2007-09-02 17:34:54 +02:00 committed by Witold Filipczyk
parent f3d9f647f0
commit ff7dfd74bc

View File

@ -34,6 +34,7 @@
#include "mime/mime.h"
#include "osdep/osdep.h" /* For exe() */
#include "session/session.h"
#include "util/env.h"
#include "util/file.h"
#include "util/hash.h"
#include "util/lists.h"
@ -633,18 +634,29 @@ get_mailcap_entry(unsigned char *type)
}
static struct mime_handler *
get_mime_handler_mailcap(unsigned char *type, int options)
get_mime_handler_mailcap(unsigned char *type, int x_win)
{
struct mailcap_entry *entry;
struct mime_handler *handler;
unsigned char *program;
unsigned char *display;
int block;
if (!get_mailcap_enable()
|| (!mailcap_map && !init_mailcap_map()))
return NULL;
/* Test for DISPLAY. */
display = getenv("DISPLAY");
if (x_win) env_set("DISPLAY", ":0", -1);
else unsetenv("DISPLAY");
entry = get_mailcap_entry(type);
/* Restore DISPLAY. */
if (display) env_set("DISPLAY", display, -1);
else unsetenv("DISPLAY");
if (!entry) return NULL;
program = format_command(entry->command, type, entry->copiousoutput);