diff --git a/ChangeLog.asciidoc b/ChangeLog.asciidoc index 441110c11..3e3c63d4d 100644 --- a/ChangeLog.asciidoc +++ b/ChangeLog.asciidoc @@ -67,6 +67,7 @@ https://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes] * core: fix truncated messages after a word with a length of zero on screen (for example a zero width space: U+200B) (bug #40985, issue #502) * api: fix handle of invalid escape in function string_convert_escaped_chars() +* alias: do not allow slashes and spaces in alias name (issue #646) * irc: add a missing colon before the password in PASS message, if the password has spaces or begins with a colon (issue #602) * irc: fix charset decoding in incoming private messages (issue #520) diff --git a/po/cs.po b/po/cs.po index 2213da4e3..bf536e2be 100644 --- a/po/cs.po +++ b/po/cs.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2016-01-03 08:56+0100\n" +"POT-Creation-Date: 2016-01-05 07:28+0100\n" "PO-Revision-Date: 2015-12-20 17:33+0100\n" "Last-Translator: Ondřej Súkup \n" "Language-Team: weechat-dev \n" @@ -4456,6 +4456,10 @@ msgstr "alias pro barvu" msgid "%s%s: error, circular reference when calling alias \"%s\"" msgstr "%s%s: chyba, cyklický odkaz při volání aliasu \"%s\"" +#, fuzzy, c-format +msgid "%s%s: invalid alias name: \"%s\"" +msgstr "%s%s: nekorektní znaková sada: \"%s\"" + #, c-format msgid "%s%s: error creating alias \"%s\" => \"%s\"" msgstr "%s%s: chyba vytváření aliasu \"%s\" => \"%s\"" diff --git a/po/de.po b/po/de.po index 766d2891d..d075a4984 100644 --- a/po/de.po +++ b/po/de.po @@ -19,7 +19,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2016-01-03 08:56+0100\n" +"POT-Creation-Date: 2016-01-05 07:28+0100\n" "PO-Revision-Date: 2016-01-03 22:25+0100\n" "Last-Translator: Nils Görs \n" "Language-Team: German <>\n" @@ -5221,6 +5221,10 @@ msgstr "Alias-Befehle" msgid "%s%s: error, circular reference when calling alias \"%s\"" msgstr "%s%s: Fehler, Zirkelbezug beim Aufruf des Alias \"%s\"" +#, fuzzy, c-format +msgid "%s%s: invalid alias name: \"%s\"" +msgstr "%s%s: Ungültiger Zeichensatz: \"%s\"" + #, c-format msgid "%s%s: error creating alias \"%s\" => \"%s\"" msgstr "%s%s: Fehler beim Erstellen von Alias \"%s\" => \"%s\"" diff --git a/po/es.po b/po/es.po index c5a5f0f7b..5fe219c71 100644 --- a/po/es.po +++ b/po/es.po @@ -22,7 +22,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2016-01-03 08:56+0100\n" +"POT-Creation-Date: 2016-01-05 07:28+0100\n" "PO-Revision-Date: 2015-12-02 19:26+0100\n" "Last-Translator: Elián Hanisch \n" "Language-Team: weechat-dev \n" @@ -4651,6 +4651,10 @@ msgstr "Alias de comandos" msgid "%s%s: error, circular reference when calling alias \"%s\"" msgstr "%s%s: error, referencia circular al ejecutar el alias \"%s\"" +#, fuzzy, c-format +msgid "%s%s: invalid alias name: \"%s\"" +msgstr "%s%s: set de caracteres inválido: \"%s\"" + #, c-format msgid "%s%s: error creating alias \"%s\" => \"%s\"" msgstr "%s%s: error al crear el alias \"%s\" => \"%s\"" diff --git a/po/fr.po b/po/fr.po index 2a02c099c..478a2689d 100644 --- a/po/fr.po +++ b/po/fr.po @@ -21,8 +21,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2016-01-03 08:56+0100\n" -"PO-Revision-Date: 2016-01-03 08:56+0100\n" +"POT-Creation-Date: 2016-01-05 07:28+0100\n" +"PO-Revision-Date: 2016-01-05 07:28+0100\n" "Last-Translator: Sébastien Helleu \n" "Language-Team: weechat-dev \n" "Language: fr\n" @@ -5113,6 +5113,10 @@ msgstr "Commandes d'alias" msgid "%s%s: error, circular reference when calling alias \"%s\"" msgstr "%s%s : erreur, référence circulaire lors de l'appel à l'alias \"%s\"" +#, c-format +msgid "%s%s: invalid alias name: \"%s\"" +msgstr "%s%s : nom d'alias invalide : \"%s\"" + #, c-format msgid "%s%s: error creating alias \"%s\" => \"%s\"" msgstr "%s%s : erreur en création de l'alias \"%s\" => \"%s\"" diff --git a/po/hu.po b/po/hu.po index 864888feb..254deca9e 100644 --- a/po/hu.po +++ b/po/hu.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2016-01-03 08:56+0100\n" +"POT-Creation-Date: 2016-01-05 07:28+0100\n" "PO-Revision-Date: 2015-12-02 19:26+0100\n" "Last-Translator: Andras Voroskoi \n" "Language-Team: weechat-dev \n" @@ -4045,6 +4045,10 @@ msgstr "%s belső parancsok:\n" msgid "%s%s: error, circular reference when calling alias \"%s\"" msgstr "%s körreferencia a \"/%s\" aliasz hívásakor\n" +#, fuzzy, c-format +msgid "%s%s: invalid alias name: \"%s\"" +msgstr "Nem sikerült a(z) \"%s\" naplófájlt írni\n" + #, fuzzy, c-format msgid "%s%s: error creating alias \"%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 e8f7753f8..ae1dd1e61 100644 --- a/po/it.po +++ b/po/it.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2016-01-03 08:56+0100\n" +"POT-Creation-Date: 2016-01-05 07:28+0100\n" "PO-Revision-Date: 2015-12-02 19:26+0100\n" "Last-Translator: Esteban I. Ruiz Moreno \n" "Language-Team: weechat-dev \n" @@ -4784,6 +4784,10 @@ msgstr "Alias dei comandi" msgid "%s%s: error, circular reference when calling alias \"%s\"" msgstr "%s%s: errore, riferimento circolare alla chiamata dell'alias \"%s\"" +#, fuzzy, c-format +msgid "%s%s: invalid alias name: \"%s\"" +msgstr "%s%s: set di caratter invalido: \"%s\"" + #, c-format msgid "%s%s: error creating alias \"%s\" => \"%s\"" msgstr "%s%s: errore nella creazione dell'alias \"%s\" => \"%s\"" diff --git a/po/ja.po b/po/ja.po index a78de482c..38f4b1ea8 100644 --- a/po/ja.po +++ b/po/ja.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2016-01-03 08:56+0100\n" +"POT-Creation-Date: 2016-01-05 07:28+0100\n" "PO-Revision-Date: 2016-01-05 09:00+0900\n" "Last-Translator: AYANOKOUZI, Ryuunosuke \n" "Language-Team: Japanese \n" @@ -4887,6 +4887,10 @@ msgstr "別名コマンド" msgid "%s%s: error, circular reference when calling alias \"%s\"" msgstr "%s%s: エラー、別名 \"%s\" の呼び出し中に循環参照を検知" +#, fuzzy, c-format +msgid "%s%s: invalid alias name: \"%s\"" +msgstr "%s%s: 不正な文字セット: \"%s\"" + #, c-format msgid "%s%s: error creating alias \"%s\" => \"%s\"" msgstr "%s%s: 別名 \"%s\" => \"%s\" 作成中にエラー" diff --git a/po/pl.po b/po/pl.po index a5102cb0e..e7c531664 100644 --- a/po/pl.po +++ b/po/pl.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2016-01-03 08:56+0100\n" +"POT-Creation-Date: 2016-01-05 07:28+0100\n" "PO-Revision-Date: 2015-12-02 19:26+0100\n" "Last-Translator: Krzysztof Korościk \n" "Language-Team: weechat-dev \n" @@ -5008,6 +5008,10 @@ msgstr "Aliasy komend" msgid "%s%s: error, circular reference when calling alias \"%s\"" msgstr "%s%s: błąd, cykliczna referencja przy wywoływaniu aliasu \"%s\"" +#, fuzzy, c-format +msgid "%s%s: invalid alias name: \"%s\"" +msgstr "%s%s: nieprawidłowe kodowanie: \"%s\"" + #, c-format msgid "%s%s: error creating alias \"%s\" => \"%s\"" msgstr "%s%s: błąd podczas tworzenia aliasu \"%s\" => \"%s\"" diff --git a/po/pt_BR.po b/po/pt_BR.po index 5a9c84e5b..c4e508341 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2016-01-03 08:56+0100\n" +"POT-Creation-Date: 2016-01-05 07:28+0100\n" "PO-Revision-Date: 2015-09-30 20:56+0200\n" "Last-Translator: Eduardo Elias \n" "Language-Team: weechat-dev \n" @@ -4637,6 +4637,10 @@ msgstr "comandos do weechat" msgid "%s%s: error, circular reference when calling alias \"%s\"" msgstr "%s%s: erro, referência circular ao chamar atalho \"%s\"" +#, fuzzy, c-format +msgid "%s%s: invalid alias name: \"%s\"" +msgstr "%s%s: charset inválido: \"%s\"" + #, c-format msgid "%s%s: error creating alias \"%s\" => \"%s\"" msgstr "%s%s: erro ao criar atalho \"%s\" => \"%s\"" diff --git a/po/ru.po b/po/ru.po index 462e61ed2..e2d61dc30 100644 --- a/po/ru.po +++ b/po/ru.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2016-01-03 08:56+0100\n" +"POT-Creation-Date: 2016-01-05 07:28+0100\n" "PO-Revision-Date: 2015-12-02 19:26+0100\n" "Last-Translator: Aleksey V Zapparov AKA ixti \n" "Language-Team: weechat-dev \n" @@ -4084,6 +4084,10 @@ msgstr "Внутренние команды %s:\n" msgid "%s%s: error, circular reference when calling alias \"%s\"" msgstr "%s рекурсия при вызове сокращения \"/%s\"\n" +#, fuzzy, c-format +msgid "%s%s: invalid alias name: \"%s\"" +msgstr "Не могу записать лог-файл \"%s\"\n" + #, fuzzy, c-format msgid "%s%s: error creating alias \"%s\" => \"%s\"" msgstr "%s недостаточно памяти для сообщения в строке информации\n" diff --git a/po/tr.po b/po/tr.po index ae7547a7b..b9cd0c1b2 100644 --- a/po/tr.po +++ b/po/tr.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2016-01-03 08:56+0100\n" +"POT-Creation-Date: 2016-01-05 07:28+0100\n" "PO-Revision-Date: 2015-03-10 21:33+0100\n" "Last-Translator: Hasan Kiran \n" "Language-Team: weechat-dev \n" @@ -3664,6 +3664,10 @@ msgstr "" msgid "%s%s: error, circular reference when calling alias \"%s\"" msgstr "" +#, fuzzy, c-format +msgid "%s%s: invalid alias name: \"%s\"" +msgstr "%sHata: dosya \"%s\" oluşturulamaz" + #, c-format msgid "%s%s: error creating alias \"%s\" => \"%s\"" msgstr "" diff --git a/po/weechat.pot b/po/weechat.pot index 181215a94..5f1b3c09d 100644 --- a/po/weechat.pot +++ b/po/weechat.pot @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2016-01-03 08:56+0100\n" +"POT-Creation-Date: 2016-01-05 07:28+0100\n" "PO-Revision-Date: 2014-08-16 10:27+0200\n" "Last-Translator: Sébastien Helleu \n" "Language-Team: weechat-dev \n" @@ -3656,6 +3656,10 @@ msgstr "" msgid "%s%s: error, circular reference when calling alias \"%s\"" msgstr "" +#, c-format +msgid "%s%s: invalid alias name: \"%s\"" +msgstr "" + #, c-format msgid "%s%s: error creating alias \"%s\" => \"%s\"" msgstr "" diff --git a/src/plugins/alias/alias.c b/src/plugins/alias/alias.c index 129f9bf72..db02f987c 100644 --- a/src/plugins/alias/alias.c +++ b/src/plugins/alias/alias.c @@ -571,6 +571,33 @@ alias_update_completion (struct t_alias *alias, const char *completion) alias_hook_command (alias); } +/* + * Checks if an alias name is valid: it must not contain any slashes nor + * any spaces. + * + * Returns: + * 1: name is valid + * 0: name is invalid + */ + +int +alias_name_valid (const char *name) +{ + if (!name || !name[0]) + return 0; + + /* no spaces allowed */ + if (strchr (name, ' ')) + return 0; + + /* no slashes allowed */ + if (strchr (name, '/')) + return 0; + + /* name is valid */ + return 1; +} + /* * Creates a new alias and adds it to alias list. * @@ -582,7 +609,16 @@ alias_new (const char *name, const char *command, const char *completion) { struct t_alias *new_alias, *ptr_alias, *pos_alias; - if (!name || !name[0] || !command || !command[0]) + if (!alias_name_valid (name)) + { + weechat_printf (NULL, + _("%s%s: invalid alias name: \"%s\""), + weechat_prefix ("error"), ALIAS_PLUGIN_NAME, + name); + return NULL; + } + + if (!command || !command[0]) return NULL; while (weechat_string_is_command_char (name))