diff --git a/src/wikitextprocessor/luaexec.py b/src/wikitextprocessor/luaexec.py index 20ebc272..028605a9 100644 --- a/src/wikitextprocessor/luaexec.py +++ b/src/wikitextprocessor/luaexec.py @@ -490,7 +490,6 @@ def make_frame( frame_args = {} for k, arg in args.items(): arg = re.sub(r"(?si)<\s*noinclude\s*/\s*>", "", arg) - arg = html.unescape(arg) frame_args[k] = arg else: assert isinstance(args, (list, tuple)) @@ -528,7 +527,6 @@ def make_frame( # does not always like them (e.g., remove_links() in # Module:links). arg = re.sub(r"(?si)<\s*noinclude\s*/\s*>", "", arg) - arg = html.unescape(arg) frame_args[k] = arg frame_args_lt: "_LuaTable" = lua.table_from(frame_args) # type: ignore[union-attr] diff --git a/tests/test_node_expand.py b/tests/test_node_expand.py index 7eec7914..2d4c4f07 100644 --- a/tests/test_node_expand.py +++ b/tests/test_node_expand.py @@ -3,10 +3,9 @@ # Copyright (c) 2020-2021 Tatu Ylonen. See file LICENSE and https://ylonen.org import unittest - from unittest.mock import patch -from wikitextprocessor import Wtp, Page +from wikitextprocessor import Page, Wtp class NodeExpTests(unittest.TestCase): @@ -206,7 +205,6 @@ def test_blank_template(self, mock_get_page) -> None: """ self.totext("{{blank template}}", "") - def test_language_converter_placeholder(self) -> None: # "-{}-" template argument shouldn't be cleaned before invoke Lua module # GitHub issue #59 @@ -215,7 +213,7 @@ def test_language_converter_placeholder(self) -> None: self.ctx.add_page( "Template:Ja-romanization of", 10, - "{{#invoke:form of/templates|form_of_t|-{}-|withcap=1|lang=ja}}" + "{{#invoke:form of/templates|form_of_t|-{}-|withcap=1|lang=ja}}", ) # https://zh.wiktionary.org/wiki/Module:Form_of/templates self.ctx.add_page( @@ -232,11 +230,38 @@ def test_language_converter_placeholder(self) -> None: end return export """, - model="Scribunto" + model="Scribunto", ) self.ctx.db_conn.commit() self.ctx.start_page("test_page") self.assertEqual( self.ctx.expand("{{ja-romanization of|まんが}}"), - "[[まんが#日語|まんが]] " + "[[まんが#日語|まんが]] ", + ) + + def test_lua_module_args_not_unescaped(self): + # https://en.wiktionary.org/wiki/Gendergap + self.ctx.add_page( + "Template:quote-journal", + 10, + "{{#invoke:quote|quote_t|type=journal}}", + ) + self.ctx.add_page( + "Module:quote", + 828, + """ + local export = {} + function export.quote_t(frame) + return frame:getParent().args.title + end + return export + """, + model="Scribunto", + ) + self.ctx.start_page("Gendergap") + self.assertEqual( + self.ctx.expand( + "{{quote-journal|de|title=re:publica 2014, der 1.}}" + ), + "re:publica 2014, der 1.", )