i18n: Skip and warn about textdomain names with a slash (bug #23839)

boost::locale::generator::add_messages_domain() interprets the slash
specially, interpreting everything after it as an encoding name.

It's not clear to me why providing a textdomain with an erroneous name
like this causes Boost.Locale to throw a boost::locale::conv exception
(invalid_charset_error, apparently) when handling t_strings bound to
completely different textdomain, but if we can avoid the issue
altogether then that's good enough.

Made the legacy implementation skip and warn about these names too even
if bindtextdomain(3) says nothing about slashes having a meaning.
This commit is contained in:
Ignacio R. Morelle 2015-08-31 21:50:19 -03:00
parent 28df1449e8
commit 352a432171
4 changed files with 24 additions and 0 deletions

View file

@ -7,6 +7,8 @@ Version 1.12.4+dev:
(units misssing fron carryover, units appering twice on map...)
* Language and i18n:
* Updated translations: French, Japanese, Latvian
* Fixed crashes during start-up on Windows resulting from add-ons containing
erroneous textdomain declarations (bug #23839).
* Multiplayer:
* Era names no longer support formatting markup in the game setup screen.
* Made MP lobby filter option filter on eras and mods too (bug #22987).

View file

@ -5,6 +5,8 @@ changelog: https://github.com/wesnoth/wesnoth/blob/1.12/changelog
Version 1.12.4+dev:
* Language and i18n:
* Updated translations: French, Japanese, Latvian.
* Fixed crashes during start-up on Windows resulting from add-ons containing
erroneous textdomain declarations (bug #23839).
* User interface:
* Force uniform font rendering settings across X11 and Apple OS X, avoiding

View file

@ -108,6 +108,14 @@ std::string dsngettext (const char * domainname, const char *singular, const cha
void bind_textdomain(const char* domain, const char* directory, const char* encoding)
{
if(domain != NULL && strchr(domain, '/') != NULL) {
// For compatibility with Boost.Locale implementation, which interprets
// slashes in domain names in a special fashion.
ERR_G << "illegal textdomain name '" << domain
<< "', skipping textdomain\n";
return;
}
if(directory != NULL)
bindtextdomain(domain, directory);
if(encoding != NULL)

View file

@ -96,6 +96,18 @@ namespace
{
return;
}
if(domain.find('/') != std::string::npos)
{
// Forward slash has a specific meaning in Boost.Locale domain
// names, specifying the encoding. We use UTF-8 for everything
// so we can't possibly support that, and odds are it's a user
// mistake (as in bug #23839).
ERR_G << "illegal textdomain name '" << domain
<< "', skipping textdomain\n";
return;
}
generator_.add_messages_domain(domain);
loaded_domains_.insert(domain);
}