diff --git a/changelog.md b/changelog.md index 1adfe3ec113..e5e3123fdc9 100644 --- a/changelog.md +++ b/changelog.md @@ -50,6 +50,7 @@ * wml.tostring() now outputs a string that can be parsed back to WML without loss of data. * Add wml.clone() function that performs a deep copy of a config or vconfig. * Organize API functions into several new (sub)modules: gui, wesnoth.units, wesnoth.interface + * Allow WML tag names injected with wml.tag to start with underscores. ### User Interface * Don't show in the sidebar the time of day schedule of a shrouded hex. (issue #3638) ### Packaging diff --git a/data/test/scenarios/test_lua_wml_tagnames.cfg b/data/test/scenarios/test_lua_wml_tagnames.cfg index 5435ef2efde..87e103ae55d 100644 --- a/data/test/scenarios/test_lua_wml_tagnames.cfg +++ b/data/test/scenarios/test_lua_wml_tagnames.cfg @@ -56,12 +56,18 @@ wml.tostring(table) end)) - -- Tag names can't start with underscores. - assert_equal(false, pcall(function() + -- Tag names can start with underscores. + assert_equal(true, pcall(function() local table = {T._reserved {}} wml.tostring(table) end)) + -- An underscore by itself isn't allowed. + assert_equal(false, pcall(function() + local table = {T._ {}} + wml.tostring(table) + end)) + -- Commit 13a4822d made the WML parser accept dollar signs in tag names. -- However, they are supposed to be rejected, and this test enforces -- that at least the Lua API rejects them. diff --git a/src/scripting/lua_common.cpp b/src/scripting/lua_common.cpp index ccf3fb4899b..f1924ba64d7 100644 --- a/src/scripting/lua_common.cpp +++ b/src/scripting/lua_common.cpp @@ -757,7 +757,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) || m[0] == '_') return_misformed(); + if (!m || !config::valid_tag(m)) return_misformed(); lua_rawgeti(L, -2, 2); if (!luaW_toconfig(L, -1, cfg.add_child(m))) return_misformed();