Skip to content

Commit

Permalink
Allow WML tags with leading underscore (#3877)
Browse files Browse the repository at this point in the history
@gfgtdf pointed out that the WML parser can deal with such tags after all.
I had missed that when I implemented the check that the game state is
valid WML before saving it (commit 3bc36ef).

Such tags are still disallowed in the Lua API because allowing them would
be an API change.
  • Loading branch information
jyrkive committed Jan 18, 2019
1 parent e0aa686 commit 07bf003
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/config.cpp
Expand Up @@ -186,8 +186,8 @@ bool config::valid_tag(config_key_type name)
if(name == "") {
// Empty strings not allowed
return false;
} else if(name[0] == '_') {
// Underscore can't be the first character
} else if(name == "_") {
// A lone underscore isn't a valid tag name
return false;
} else {
return std::all_of(name.begin(), name.end(), [](const char& c)
Expand Down
2 changes: 1 addition & 1 deletion src/scripting/lua_common.cpp
Expand Up @@ -745,7 +745,7 @@ bool luaW_toconfig(lua_State *L, int index, config &cfg)
if (!lua_istable(L, -1)) return_misformed();
lua_rawgeti(L, -1, 1);
char const *m = lua_tostring(L, -1);
if (!m || !config::valid_tag(m)) return_misformed();
if (!m || !config::valid_tag(m) || m[0] == '_') return_misformed();
lua_rawgeti(L, -2, 2);
if (!luaW_toconfig(L, -1, cfg.add_child(m)))
return_misformed();
Expand Down

0 comments on commit 07bf003

Please sign in to comment.