Sanitize string read from file before sending to player.
This commit is contained in:
parent
06bcf00013
commit
877de10cba
2 changed files with 14 additions and 2 deletions
|
|
@ -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")]
|
||||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue