1308 |
list_do (*list, _run_and_free, NULL); |
list_do (*list, _run_and_free, NULL); |
1309 |
list_destroy (list); |
list_destroy (list); |
1310 |
} |
} |
1311 |
|
|
1312 |
|
void |
1313 |
|
util_rfc2047_decode (char **value) |
1314 |
|
{ |
1315 |
|
char *charset = NULL; |
1316 |
|
char *tmp; |
1317 |
|
int rc; |
1318 |
|
|
1319 |
|
if (!*value || util_getenv (&charset, "charset", Mail_env_string, 0)) |
1320 |
|
return; |
1321 |
|
if (strcasecmp (charset, "auto") == 0) |
1322 |
|
{ |
1323 |
|
/* Try to deduce the charset from LC_ALL variable */ |
1324 |
|
|
1325 |
|
tmp = getenv ("LC_ALL"); |
1326 |
|
if (tmp) |
1327 |
|
{ |
1328 |
|
char *sp; |
1329 |
|
char *lang; |
1330 |
|
char *terr; |
1331 |
|
|
1332 |
|
lang = strtok_r (tmp, "_", &sp); |
1333 |
|
terr = strtok_r (NULL, ".", &sp); |
1334 |
|
charset = strtok_r (NULL, "@", &sp); |
1335 |
|
|
1336 |
|
if (!charset) |
1337 |
|
charset = mu_charset_lookup (lang, terr); |
1338 |
|
} |
1339 |
|
} |
1340 |
|
|
1341 |
|
if (!charset) |
1342 |
|
return; |
1343 |
|
|
1344 |
|
rc = rfc2047_decode (charset, *value, &tmp); |
1345 |
|
if (rc) |
1346 |
|
{ |
1347 |
|
if (util_getenv (NULL, "verbose", Mail_env_boolean, 0) == 0) |
1348 |
|
mu_error (_("Can't decode line `%s': %s"), *value, mu_strerror (rc)); |
1349 |
|
} |
1350 |
|
else |
1351 |
|
{ |
1352 |
|
free (*value); |
1353 |
|
*value = tmp; |
1354 |
|
} |
1355 |
|
} |