• Print

Author Topic: Adding a "string.sanitize" function.  (Read 5628 times)

0 Members and 1 Guest are viewing this topic.

Offline LuaTenshi

  • Hero Member
  • *****
  • Posts: 545
  • Karma: 47
  • Just your ordinary moon angel!
    • Mirai.Red
Adding a "string.sanitize" function.
« on: October 08, 2013, 03:06:17 pm »
I think a function that would remove "dangerous" characters from a string may be needed, it would help with things such as integration with SQL.



Code: Lua
  1. function string.sanitise( str )
  2.         return string.Trim(string.Replace(string.Replace(string.Replace( tostring(str), "\\", "/" ), "\"", ""), ";", ""))
  3. end

I felt that a function like the one above was always missing from Garrysmod, and I am sure that we had problems because of it.

I hope that if a function like the one above is added to ULX, that it would help many developers in the long run.
I cry every time I see that I am not a respected member of this community.

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Adding a "string.sanitize" function.
« Reply #1 on: October 08, 2013, 06:21:31 pm »
This is the job of the individual SQL library, as escape methods differ. Just like the one GMod includes.
Experiencing God's grace one day at a time.

  • Print