Skip to content

Commit faa3ba5

Browse files
Bugfix #36
Fixed SUP check to prevent user from adding empty values to the table, and to prevent them from adding only whitespaces or strings that accidentally end with a whitespace
1 parent 3cc1a3c commit faa3ba5

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

lua/msync/client_gui/modules/cl_mrsync.lua

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,15 @@ function MSync.modules.MRSync.adminPanel(sheet)
7171
allserver_button:SetPos( 275, 15 )
7272
allserver_button:SetSize( 130, 20 )
7373
allserver_button.DoClick = function()
74-
if not allserver_textentry:GetValue() == "" and not MSync.modules.MRSync.settings.nosync[allserver_textentry:GetValue()] and not MSync.modules.MRSync.settings.syncall[allserver_textentry:GetValue()] then
74+
if string.len(allserver_textentry:GetValue()) > 0 and not MSync.modules.MRSync.settings.nosync[allserver_textentry:GetValue()] and not MSync.modules.MRSync.settings.syncall[allserver_textentry:GetValue()] then
75+
if string.match(allserver_textentry:GetValue(), "^%s*$") or string.match(allserver_textentry:GetValue(), "%s+$") then return end
7576
allserver_table:AddLine(allserver_textentry:GetValue())
7677
MSync.modules.MRSync.settings.syncall[allserver_textentry:GetValue()] = true
7778
allserver_textentry:SetText("")
7879
MSync.modules.MRSync.sendSettings()
7980
end
8081
end
8182

82-
83-
84-
8583
local nosync_text = vgui.Create( "DLabel", pnl )
8684
nosync_text:SetPos( 25, 140 )
8785
nosync_text:SetColor( Color( 0, 0, 0 ) )
@@ -120,18 +118,19 @@ function MSync.modules.MRSync.adminPanel(sheet)
120118
nosync_button:SetPos( 275, 155 )
121119
nosync_button:SetSize( 130, 20 )
122120
nosync_button.DoClick = function()
123-
if not nosync_textentry:GetValue() == "" and not MSync.modules.MRSync.settings.nosync[nosync_textentry:GetValue()] and not MSync.modules.MRSync.settings.syncall[nosync_textentry:GetValue()] then
121+
if string.len(nosync_textentry:GetValue()) > 0 and not MSync.modules.MRSync.settings.nosync[nosync_textentry:GetValue()] and not MSync.modules.MRSync.settings.syncall[nosync_textentry:GetValue()] then
122+
if string.match(nosync_textentry:GetValue(), "^%s*$") or string.match(nosync_textentry:GetValue(), "%s+$") then return end
124123
nosync_table:AddLine(nosync_textentry:GetValue())
125124
MSync.modules.MRSync.settings.nosync[nosync_textentry:GetValue()] = true
126125
nosync_textentry:SetText("")
127126
MSync.modules.MRSync.sendSettings()
128127
end
129128
end
130129

131-
--if MSync.DBStatus then
132-
MSync.modules.MRSync.getSettings()
133-
--end
130+
-- Load settings from the server
131+
MSync.modules.MRSync.getSettings()
134132

133+
-- Wait for settings from the server
135134
if not MSync.modules.MRSync.settings then
136135
timer.Create("mrsync.t.checkSettings", 1, 0, function()
137136
if not MSync.modules.MRSync.settings then return end

0 commit comments

Comments
 (0)