Sanitize string read from file before sending to player.

This commit is contained in:
Deathmax 2011-12-23 16:54:01 +08:00
parent 06bcf00013
commit 877de10cba
2 changed files with 14 additions and 2 deletions

View file

@ -35,5 +35,5 @@ using System.Runtime.InteropServices;
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.4.1.1222")]
[assembly: AssemblyFileVersion("3.4.1.1222")]
[assembly: AssemblyVersion("3.4.1.1223")]
[assembly: AssemblyFileVersion("3.4.1.1223")]

View file

@ -468,6 +468,7 @@ namespace TShockAPI
{
foo = foo.Replace("%map%", Main.worldName);
foo = foo.Replace("%players%", GetPlayers());
foo = SanitizeString(foo);
if (foo.Substring(0, 1) == "%" && foo.Substring(12, 1) == "%") //Look for a beginning color code.
{
string possibleColor = foo.Substring(0, 13);
@ -611,5 +612,16 @@ namespace TShockAPI
}
return 1000;
}
public string SanitizeString(string str)
{
var returnstr = str.ToCharArray();
for (int i = 0; i < str.Length; i++)
{
if (!ValidString(str[i].ToString()))
returnstr[i] = ' ';
}
return returnstr.ToString();
}
}
}