Skip to content

Commit fb9862a

Browse files
authored
freeroam: fix exploit to get around hex code removal (#194)
Previously `#00ff00color #00ff#ffffff00code` would strip down to `color #00ff00code`, allowing you to get around the hex code removal. This has now been fixed.
1 parent 38d7086 commit fb9862a

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

[gameplay]/freeroam/fr_server.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ addEventHandler('onPlayerChat', root,
443443
end
444444
if isElement(source) then
445445
local r, g, b = getPlayerNametagColor(source)
446-
outputChatBox(getPlayerName(source) .. ': #FFFFFF' .. msg:gsub('#%x%x%x%x%x%x', ''), root, r, g, b, true)
446+
outputChatBox(getPlayerName(source) .. ': #FFFFFF' .. stripHex(msg), root, r, g, b, true)
447447
outputServerLog( "CHAT: " .. getPlayerName(source) .. ": " .. msg )
448448
end
449449
end

[gameplay]/freeroam/util_server.lua

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@ function errMsg(msg, player)
1717
outputChatBox(msg, player or root, 255, 0, 0)
1818
end
1919

20+
function stripHex(str)
21+
local oldLen
22+
repeat
23+
oldLen = str:len()
24+
str = str:gsub('#%x%x%x%x%x%x', '')
25+
until str:len() == oldLen
26+
return str
27+
end
28+
2029
function table.find(t, ...)
2130
local args = { ... }
2231
if #args == 0 then

0 commit comments

Comments
 (0)