From f4dc85a3cb6d17b219f94fb01f3109878f79a7a3 Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Sat, 14 Jul 2012 10:50:49 +0200 Subject: [PATCH] charset: do not allow "UTF-8" in charset options (useless because UTF-8 is the internal WeeChat charset) --- ChangeLog | 4 ++- po/cs.po | 9 +++++- po/de.po | 9 +++++- po/es.po | 9 +++++- po/fr.po | 14 ++++++-- po/hu.po | 9 +++++- po/it.po | 9 +++++- po/ja.po | 9 +++++- po/pl.po | 9 +++++- po/pt_BR.po | 9 +++++- po/ru.po | 9 +++++- po/weechat.pot | 9 +++++- src/plugins/charset/charset.c | 61 +++++++++++++++++++++++++++++------ 13 files changed, 147 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9af7aceff..39b5ba054 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,7 @@ WeeChat ChangeLog ================= Sébastien Helleu -v0.3.9-dev, 2012-07-13 +v0.3.9-dev, 2012-07-14 Version 0.3.9 (under dev!) @@ -30,6 +30,8 @@ Version 0.3.9 (under dev!) command /aspell (rename options enable/disable/dictlist to setdict/deldict/listdict), display aspell status with /aspell (task #11988) * aspell: add missing dictionaries (ast/grc/hus/kn/ky) +* charset: do not allow "UTF-8" in charset options (useless because UTF-8 is the + internal WeeChat charset) * guile: fix crash when unloading a script without pointer to interpreter * guile: fix path of guile include dirs in cmake build (patch #7790) * irc: add bar item "buffer_modes", remove option irc.look.item_channel_modes diff --git a/po/cs.po b/po/cs.po index c5f56250e..848782790 100644 --- a/po/cs.po +++ b/po/cs.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.9-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2012-07-13 10:55+0200\n" +"POT-Creation-Date: 2012-07-14 10:46+0200\n" "PO-Revision-Date: 2012-06-03 09:49+0200\n" "Last-Translator: Jiri Golembiovsky \n" "Language-Team: weechat-dev \n" @@ -3755,6 +3755,13 @@ msgstr "%s: upozornění: slovník \"%s\" není dostupný ve vašem systému" msgid "%s%s: not enough memory to create new speller" msgstr "%s%s: nedostatek paměti pro vytvoření kontroly pravopisu" +#, c-format +msgid "" +"%s%s: UTF-8 is now allowed in charset options (it is internal and default " +"charset: default encode is UTF-8 and decode of UTF-8 is OK even if you " +"specify another charset to decode)" +msgstr "" + #, c-format msgid "%s%s: error creating charset \"%s\" => \"%s\"" msgstr "%s%s: chyba vytváření znakové sady \"%s\" => \"%s\"" diff --git a/po/de.po b/po/de.po index 6cb19d86e..4cfe27e66 100644 --- a/po/de.po +++ b/po/de.po @@ -23,7 +23,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2012-07-13 10:55+0200\n" +"POT-Creation-Date: 2012-07-14 10:46+0200\n" "PO-Revision-Date: 2012-06-30 14:28+0100\n" "Last-Translator: Nils Görs \n" "Language-Team: German \n" @@ -4113,6 +4113,13 @@ msgstr "%s: Hinweis: das Wörterbuch \"%s\" ist auf dem Rechner nicht verfügbar msgid "%s%s: not enough memory to create new speller" msgstr "%s%s: Nicht genug Speicher um neue Rechtschreibung zu erstellen" +#, c-format +msgid "" +"%s%s: UTF-8 is now allowed in charset options (it is internal and default " +"charset: default encode is UTF-8 and decode of UTF-8 is OK even if you " +"specify another charset to decode)" +msgstr "" + #, c-format msgid "%s%s: error creating charset \"%s\" => \"%s\"" msgstr "%s%s: Fehler bei der Erstellung des Zeichensatzes \"%s\" => \"%s\"" diff --git a/po/es.po b/po/es.po index 3466a3e40..dce8f5d22 100644 --- a/po/es.po +++ b/po/es.po @@ -22,7 +22,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.9-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2012-07-13 10:55+0200\n" +"POT-Creation-Date: 2012-07-14 10:46+0200\n" "PO-Revision-Date: 2012-06-03 09:49+0200\n" "Last-Translator: Elián Hanisch \n" "Language-Team: weechat-dev \n" @@ -3952,6 +3952,13 @@ msgstr "%s: atención: diccionario \"%s\" no está disponible en su sistema" msgid "%s%s: not enough memory to create new speller" msgstr "%s%s: no hay suficiente memoria para crear el nuevo deletreador" +#, c-format +msgid "" +"%s%s: UTF-8 is now allowed in charset options (it is internal and default " +"charset: default encode is UTF-8 and decode of UTF-8 is OK even if you " +"specify another charset to decode)" +msgstr "" + #, c-format msgid "%s%s: error creating charset \"%s\" => \"%s\"" msgstr "%s%s: error al crear el set de caracteres \"%s\" => \"%s\"" diff --git a/po/fr.po b/po/fr.po index 733bd5e8c..3b55aa4f0 100644 --- a/po/fr.po +++ b/po/fr.po @@ -21,8 +21,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.9-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2012-07-13 10:55+0200\n" -"PO-Revision-Date: 2012-07-13 10:57+0200\n" +"POT-Creation-Date: 2012-07-14 10:46+0200\n" +"PO-Revision-Date: 2012-07-14 10:46+0200\n" "Last-Translator: Sebastien Helleu \n" "Language-Team: weechat-dev \n" "Language: French\n" @@ -3989,6 +3989,16 @@ msgstr "" msgid "%s%s: not enough memory to create new speller" msgstr "%s%s: pas assez de mémoire pour créer un nouveau speller" +#, c-format +msgid "" +"%s%s: UTF-8 is now allowed in charset options (it is internal and default " +"charset: default encode is UTF-8 and decode of UTF-8 is OK even if you " +"specify another charset to decode)" +msgstr "" +"%s%s: UTF-8 n'est pas autorisé dans les options de charset (c'est le charset " +"interne et par défaut: l'encodage par défaut est UTF-8 et le décodage " +"d'UTF-8 est OK même si vous spécifiez un autre charset à décoder)" + #, c-format msgid "%s%s: error creating charset \"%s\" => \"%s\"" msgstr "%s%s: erreur en création du charset \"%s\" => \"%s\"" diff --git a/po/hu.po b/po/hu.po index 6c6b22d66..0ef55def3 100644 --- a/po/hu.po +++ b/po/hu.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.9-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2012-07-13 10:55+0200\n" +"POT-Creation-Date: 2012-07-14 10:46+0200\n" "PO-Revision-Date: 2012-06-03 09:49+0200\n" "Last-Translator: Andras Voroskoi \n" "Language-Team: weechat-dev \n" @@ -3384,6 +3384,13 @@ msgstr "" msgid "%s%s: not enough memory to create new speller" msgstr "%s nincs elegendő memória új DCC számára\n" +#, c-format +msgid "" +"%s%s: UTF-8 is now allowed in charset options (it is internal and default " +"charset: default encode is UTF-8 and decode of UTF-8 is OK even if you " +"specify another charset to decode)" +msgstr "" + #, fuzzy, c-format msgid "%s%s: error creating charset \"%s\" => \"%s\"" msgstr "%s nincs elég memória az információs pult üzenethez\n" diff --git a/po/it.po b/po/it.po index d6b3528cb..fd8c0ddcd 100644 --- a/po/it.po +++ b/po/it.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.9-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2012-07-13 10:55+0200\n" +"POT-Creation-Date: 2012-07-14 10:46+0200\n" "PO-Revision-Date: 2012-06-03 09:49+0200\n" "Last-Translator: Marco Paolone \n" "Language-Team: weechat-dev \n" @@ -3942,6 +3942,13 @@ msgstr "" msgid "%s%s: not enough memory to create new speller" msgstr "%s%s: memoria non sufficiente per creare un nuovo controllore" +#, c-format +msgid "" +"%s%s: UTF-8 is now allowed in charset options (it is internal and default " +"charset: default encode is UTF-8 and decode of UTF-8 is OK even if you " +"specify another charset to decode)" +msgstr "" + #, c-format msgid "%s%s: error creating charset \"%s\" => \"%s\"" msgstr "" diff --git a/po/ja.po b/po/ja.po index 540b08765..25d13fdf2 100644 --- a/po/ja.po +++ b/po/ja.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.9-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2012-07-13 10:55+0200\n" +"POT-Creation-Date: 2012-07-14 10:46+0200\n" "PO-Revision-Date: 2012-06-03 09:49+0200\n" "Last-Translator: AYANOKOUZI, Ryuunosuke \n" "Language-Team: Japanese \n" @@ -3841,6 +3841,13 @@ msgstr "%s: 警告: 辞書 \"%s\" がこのシステム上では利用できま msgid "%s%s: not enough memory to create new speller" msgstr "%s%s: 新しい speller を作る十分なメモリがありません" +#, c-format +msgid "" +"%s%s: UTF-8 is now allowed in charset options (it is internal and default " +"charset: default encode is UTF-8 and decode of UTF-8 is OK even if you " +"specify another charset to decode)" +msgstr "" + #, c-format msgid "%s%s: error creating charset \"%s\" => \"%s\"" msgstr "%s%s: 文字集合 \"%s\" => \"%s\" の作成中にエラー" diff --git a/po/pl.po b/po/pl.po index f330e62ce..4293c47ad 100644 --- a/po/pl.po +++ b/po/pl.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.9-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2012-07-13 10:55+0200\n" +"POT-Creation-Date: 2012-07-14 10:46+0200\n" "PO-Revision-Date: 2012-06-03 09:49+0200\n" "Last-Translator: Krzysztof Korościk \n" "Language-Team: weechat-dev \n" @@ -3930,6 +3930,13 @@ msgstr "%s: ostrzeżenie: słownik \"%s\" nie jest dostępny w Twoim systemie" msgid "%s%s: not enough memory to create new speller" msgstr "%s%s: za mało pamięci na utworzenie nowego słownika" +#, c-format +msgid "" +"%s%s: UTF-8 is now allowed in charset options (it is internal and default " +"charset: default encode is UTF-8 and decode of UTF-8 is OK even if you " +"specify another charset to decode)" +msgstr "" + #, c-format msgid "%s%s: error creating charset \"%s\" => \"%s\"" msgstr "%s%s: błąd przy tworzeniu zestawu znaków (kodowania) \"%s\" => \"%s\"" diff --git a/po/pt_BR.po b/po/pt_BR.po index cadc8c9fc..b3ebbe937 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.9-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2012-07-13 10:55+0200\n" +"POT-Creation-Date: 2012-07-14 10:46+0200\n" "PO-Revision-Date: 2012-06-03 09:49+0200\n" "Last-Translator: Sergio Durigan Junior \n" "Language-Team: weechat-dev \n" @@ -3808,6 +3808,13 @@ msgstr "%s: aviso: dicionário \"%s\" não está disponível em seu sistema" msgid "%s%s: not enough memory to create new speller" msgstr "%s%s: memória insuficiente para criar novo verificador ortográfico" +#, c-format +msgid "" +"%s%s: UTF-8 is now allowed in charset options (it is internal and default " +"charset: default encode is UTF-8 and decode of UTF-8 is OK even if you " +"specify another charset to decode)" +msgstr "" + #, c-format msgid "%s%s: error creating charset \"%s\" => \"%s\"" msgstr "%s%s: erro ao criar charset \"%s\" => \"%s\"" diff --git a/po/ru.po b/po/ru.po index 7d99a570b..5d7b57412 100644 --- a/po/ru.po +++ b/po/ru.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.9-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2012-07-13 10:55+0200\n" +"POT-Creation-Date: 2012-07-14 10:46+0200\n" "PO-Revision-Date: 2012-06-03 09:49+0200\n" "Last-Translator: Aleksey V Zapparov AKA ixti \n" "Language-Team: weechat-dev \n" @@ -3414,6 +3414,13 @@ msgstr "" msgid "%s%s: not enough memory to create new speller" msgstr "%s недостаточно памяти для нового DCC\n" +#, c-format +msgid "" +"%s%s: UTF-8 is now allowed in charset options (it is internal and default " +"charset: default encode is UTF-8 and decode of UTF-8 is OK even if you " +"specify another charset to decode)" +msgstr "" + #, fuzzy, c-format msgid "%s%s: error creating charset \"%s\" => \"%s\"" msgstr "%s недостаточно памяти для сообщения в строке информации\n" diff --git a/po/weechat.pot b/po/weechat.pot index 16c1eaf3e..e3f22c93a 100644 --- a/po/weechat.pot +++ b/po/weechat.pot @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2012-07-13 10:55+0200\n" +"POT-Creation-Date: 2012-07-14 10:46+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -2984,6 +2984,13 @@ msgstr "" msgid "%s%s: not enough memory to create new speller" msgstr "" +#, c-format +msgid "" +"%s%s: UTF-8 is now allowed in charset options (it is internal and default " +"charset: default encode is UTF-8 and decode of UTF-8 is OK even if you " +"specify another charset to decode)" +msgstr "" + #, c-format msgid "%s%s: error creating charset \"%s\" => \"%s\"" msgstr "" diff --git a/src/plugins/charset/charset.c b/src/plugins/charset/charset.c index adfb8b984..9b0b47942 100644 --- a/src/plugins/charset/charset.c +++ b/src/plugins/charset/charset.c @@ -73,6 +73,46 @@ charset_config_reload (void *data, struct t_config_file *config_file) return weechat_config_reload (config_file); } +/* + * charset_is_allowed: check if charset is allowed (different from "UTF-8", + * which is the internal charset) + * return 1 if charset is allowed, otherwise 0 + * (and error is displayed) + */ + +int +charset_is_allowed (const char *charset) +{ + if (weechat_strcasestr (charset, "utf-8") + || weechat_strcasestr (charset, "utf8")) + { + weechat_printf (NULL, + _("%s%s: UTF-8 is now allowed in charset options (it " + "is internal and default charset: default encode " + "is UTF-8 and decode of UTF-8 is OK even if you " + "specify another charset to decode)"), + weechat_prefix ("error"), CHARSET_PLUGIN_NAME); + return 0; + } + + return 1; +} + +/* + * charset_check_charset_cb: callback called to check the charset value + */ + +int +charset_check_charset_cb (void *data, struct t_config_option *option, + const char *value) +{ + /* make C compiler happy */ + (void) data; + (void) option; + + return charset_is_allowed (value); +} + /* * charset_config_create_option: set a charset */ @@ -108,13 +148,16 @@ charset_config_create_option (void *data, struct t_config_file *config_file, { if (value && value[0]) { - ptr_option = weechat_config_new_option ( - config_file, section, - option_name, "string", NULL, - NULL, 0, 0, "", value, 0, - NULL, NULL, NULL, NULL, NULL, NULL); - rc = (ptr_option) ? - WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE : WEECHAT_CONFIG_OPTION_SET_ERROR; + if (charset_is_allowed (value)) + { + ptr_option = weechat_config_new_option ( + config_file, section, + option_name, "string", NULL, + NULL, 0, 0, "", value, 0, + &charset_check_charset_cb, NULL, NULL, NULL, NULL, NULL); + rc = (ptr_option) ? + WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE : WEECHAT_CONFIG_OPTION_SET_ERROR; + } } else rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE; @@ -167,13 +210,13 @@ charset_config_init () && (strcasecmp (charset_terminal, charset_internal) != 0)) ? charset_terminal : "iso-8859-1", NULL, 0, - NULL, NULL, NULL, NULL, NULL, NULL); + &charset_check_charset_cb, NULL, NULL, NULL, NULL, NULL); charset_default_encode = weechat_config_new_option ( charset_config_file, ptr_section, "encode", "string", N_("global encoding charset"), NULL, 0, 0, "", NULL, 0, - NULL, NULL, NULL, NULL, NULL, NULL); + &charset_check_charset_cb, NULL, NULL, NULL, NULL, NULL); ptr_section = weechat_config_new_section (charset_config_file, "decode", 1, 1,