• Print

Author Topic: Bug 208  (Read 15 times)

0 Members and 1 Guest are viewing this topic.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Bug 208
« on: September 28, 2008, 05:56:14 pm »
Re : http://ulyssesmod.net/bugs/view.php?id=208

For the first time in probably months, I've looked at code not related to work (and enjoyed it, a little, gimme time. Work's killing me)
I see that ULib.addBan does no error checking for any syntax before it goes into a table and gets parsed into keyvalues.

Would the following solution fix the bug mentioned in 208?
Code: [Select]
function ULib.addBan( steamid, time, reason, name, admin )
local t = {}
t.time = os.time()
if time > 0 then
t.unban = ( ( time * 60 ) + t.time )
else
t.unban = 0
end
if reason then
t.reason = ULib.makePatternSafe( reason )
end
if name then
t.name = ULib.makePatternSafe( name )
end
if admin then
t.admin = "Console(Console)"
if admin:IsValid() then
t.admin = string.format( "%s(%s)", ULib.makePatternSafe( admin:Name() ), admin:SteamID() )
end
end
ULib.bans[ steamid ] = t
file.Write( ULib.BANS_FILE, ULib.makeKeyValues( ULib.bans ) )
end

OR, would the better method be to modify makeKeyValues to clean any strings?


Megiddo, we should probably get jay a mantis account until we decide on Flyspray or not.
He could at least assign himself anything he wants to dig into.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Bug 208
« Reply #1 on: September 28, 2008, 06:13:50 pm »
I see my idea would fail (it doesn't do anything for slashes)
Still, I wonder if it would be good for cleanup before going to makekeyvalues, or making keyvalues do the cleanup of the input.

(Wait, didn't I just say a few days ago I wouldn't be interested in unit testing)

:P
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Bug 208
« Reply #2 on: September 28, 2008, 07:09:25 pm »
Did anyone ever actually provide us with a file like this? I'd need to see it to fix it.
Experiencing God's grace one day at a time.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Bug 208
« Reply #3 on: September 28, 2008, 08:40:02 pm »
Did anyone ever actually provide us with a file like this? I'd need to see it to fix it.
We've asked, but the forum won't allow them to post a 65mb file in text, and we didn't ask them to try to zip.
Perhaps we should ask someone to post a compressed zip on the bug tracker.
Zipped, shouldn't be that large.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

  • Print