jenkins-bot has submitted this change and it was merged.
Change subject: Prevent leaking title fragments across invokes
..
Prevent leaking title fragments across invokes
Bug: T106951
Change-Id: Iace5d75deac3d8ffde6f3dec6a4f910dcb77d1e2
---
M engines/LuaCommon/lualib/mw.title.lua
M tests/engines/LuaCommon/TitleLibraryTests.lua
2 files changed, 9 insertions(+), 1 deletion(-)
Approvals:
Anomie: Looks good to me, approved
jenkins-bot: Verified
diff --git a/engines/LuaCommon/lualib/mw.title.lua
b/engines/LuaCommon/lualib/mw.title.lua
index 4459066..3a44318 100644
--- a/engines/LuaCommon/lualib/mw.title.lua
+++ b/engines/LuaCommon/lualib/mw.title.lua
@@ -290,7 +290,7 @@
-- Set current title
title.getCurrentTitle = function ()
- return makeTitleObject( options.thisTitle )
+ return makeTitleObject( mw.clone( options.thisTitle ) )
end
-- Register this library in the "mw" global
diff --git a/tests/engines/LuaCommon/TitleLibraryTests.lua
b/tests/engines/LuaCommon/TitleLibraryTests.lua
index ed7c146..b65a4f9 100644
--- a/tests/engines/LuaCommon/TitleLibraryTests.lua
+++ b/tests/engines/LuaCommon/TitleLibraryTests.lua
@@ -74,6 +74,11 @@
return mw.title.new( 'ScribuntoTestPage' ):getContent()
end
+local function test_getCurrentTitle_fragment()
+ mw.title.getCurrentTitle().fragment = 'bad'
+ return mw.title.getCurrentTitle().fragment
+end
+
-- Tests
local tests = {
{ name = 'tostring', func = identity, type = 'ToString',
@@ -382,6 +387,9 @@
{ name = "inexpensive actions shouldn't count as expensive", func =
test_inexpensive,
expect = { 'did not error' }
},
+ { name = "fragments don't leak via getCurrentTitle()", func =
test_getCurrentTitle_fragment,
+ expect = { '' }
+ },
}
return testframework.getTestProvider( tests )
--
To view, visit https://gerrit.wikimedia.org/r/226987
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Iace5d75deac3d8ffde6f3dec6a4f910dcb77d1e2
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Scribunto
Gerrit-Branch: master
Gerrit-Owner: Jackmcbarn
Gerrit-Reviewer: Anomie
Gerrit-Reviewer: Mr. Stradivarius
Gerrit-Reviewer: jenkins-bot <>
___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits