Hoo man has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/110484

Change subject: Validate the type of the tagName given to mw.html.create
......................................................................

Validate the type of the tagName given to mw.html.create

Change-Id: I35f70701ba6156325dfd268903452e6279aca528
---
M engines/LuaCommon/lualib/mw.html.lua
M tests/engines/LuaCommon/HtmlLibraryTests.lua
2 files changed, 12 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Scribunto 
refs/changes/84/110484/1

diff --git a/engines/LuaCommon/lualib/mw.html.lua 
b/engines/LuaCommon/lualib/mw.html.lua
index 33e8044..68e2f17 100644
--- a/engines/LuaCommon/lualib/mw.html.lua
+++ b/engines/LuaCommon/lualib/mw.html.lua
@@ -341,6 +341,10 @@
 -- @param tagName
 -- @param args
 function HtmlBuilder.create( tagName, args )
+       if type( tagName ) ~= 'string' then
+               error( "Tag name must be a string" )
+       end
+
        if tagName ~= '' and not isValidTag( tagName ) then
                error( "Invalid tag name: " .. tagName )
        end
diff --git a/tests/engines/LuaCommon/HtmlLibraryTests.lua 
b/tests/engines/LuaCommon/HtmlLibraryTests.lua
index 5af0f1c..b6deb74 100644
--- a/tests/engines/LuaCommon/HtmlLibraryTests.lua
+++ b/tests/engines/LuaCommon/HtmlLibraryTests.lua
@@ -108,10 +108,17 @@
          args = { 'div', { selfClosing = true } },
          expect = { '<div />' }
        },
-       { name = 'mw.html.create (invalid tag)', func = mw.html.create, 
type='ToString',
+       { name = 'mw.html.create (invalid tag 1)', func = mw.html.create, 
type='ToString',
          args = { '$$$$' },
          expect = 'Invalid tag name: $$$$'
        },
+       { name = 'mw.html.create (invalid tag 2)', func = mw.html.create, 
type='ToString',
+         args = { {} },
+         expect = 'Tag name must be a string'
+       },
+       { name = 'mw.html.create (invalid tag 3)', func = mw.html.create, 
type='ToString',
+         expect = 'Tag name must be a string'
+       },
        { name = 'mw.html.wikitext', func = testHelper, type='ToString',
          args = { getEmptyTestDiv(), 'wikitext', 'Plain text' },
          expect = { '<div>Plain text</div>' }

-- 
To view, visit https://gerrit.wikimedia.org/r/110484
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I35f70701ba6156325dfd268903452e6279aca528
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Scribunto
Gerrit-Branch: master
Gerrit-Owner: Hoo man <h...@online.de>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to