Skip to content

Commit

Permalink
i18n: Skip and warn about textdomain names with a slash (bug #23839)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
irydacea committed Sep 1, 2015
1 parent 28df144 commit 352a432
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions changelog
Expand Up @@ -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).
Expand Down
2 changes: 2 additions & 0 deletions players_changelog
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions src/gettext.cpp
Expand Up @@ -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)
Expand Down
12 changes: 12 additions & 0 deletions src/gettext_boost.cpp
Expand Up @@ -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);
}
Expand Down

0 comments on commit 352a432

Please sign in to comment.