File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
src/wikitextprocessor/lua Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -228,7 +228,11 @@ local mw_uri = {
228228
229229function mw_uri .anchorEncode (s )
230230 -- XXX how exactly should this work?
231- s = s :gsub (" " , " _" ):gsub (" *" , " *" )
231+ s = s :gsub (" " , " _" ):gsub (" &#x(%x+);" , function (hex )
232+ return string.char (tonumber (hex , 16 ))
233+ end ):gsub (" &#(%d+);" , function (num )
234+ return string.char (tonumber (num ))
235+ end )
232236 return s
233237end
234238
Original file line number Diff line number Diff line change @@ -584,3 +584,17 @@ def test_math_module_sum(self):
584584return export""" ,
585585 )
586586 self .assertEqual (self .wtp .expand ("{{#invoke:math|sum}}" ), "1" )
587+
588+ def test_mw_uri_anchorEncode (self ):
589+ # GH PR #276
590+ self .wtp .start_page ("Reconstruction:Proto-Turkic/us-" )
591+ self .wtp .add_page (
592+ "Module:test" ,
593+ 828 ,
594+ """local export = {}
595+ function export.test(frame)
596+ return mw.uri.anchorEncode("*") .. mw.uri.anchorEncode("*")
597+ end
598+ return export""" ,
599+ )
600+ self .assertEqual (self .wtp .expand ("{{#invoke:test|test}}" ), "**" )
You can’t perform that action at this time.
0 commit comments