Removed mousefontchars, valid chars are 0x20-0xA9(32-169)
Added checking to player names too.
This commit is contained in:
parent
1cd0f4c74b
commit
b382125cc5
8 changed files with 33 additions and 31 deletions
|
|
@ -134,8 +134,6 @@ namespace TShockAPI
|
|||
{
|
||||
byte playerid = args.Data.ReadInt8();
|
||||
byte hair = args.Data.ReadInt8();
|
||||
//Various colours here
|
||||
|
||||
args.Data.Position += 21;
|
||||
bool hardcore = args.Data.ReadBoolean();
|
||||
string name = Encoding.ASCII.GetString(args.Data.ReadBytes((int)(args.Data.Length - args.Data.Position - 1)));
|
||||
|
|
@ -145,6 +143,11 @@ namespace TShockAPI
|
|||
Tools.ForceKick(args.Player, "Hair crash exploit.");
|
||||
return true;
|
||||
}
|
||||
if (!Tools.ValidString(name))
|
||||
{
|
||||
Tools.ForceKick(args.Player, "Unprintable character in name");
|
||||
return true;
|
||||
}
|
||||
if (name.Length > 32)
|
||||
{
|
||||
Tools.ForceKick(args.Player, "Name exceeded 32 characters.");
|
||||
|
|
|
|||
|
|
@ -35,5 +35,5 @@ using System.Runtime.InteropServices;
|
|||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
|
||||
[assembly: AssemblyVersion("2.3.4.0708")]
|
||||
[assembly: AssemblyFileVersion("2.3.4.0708")]
|
||||
[assembly: AssemblyVersion("2.3.4.0709")]
|
||||
[assembly: AssemblyFileVersion("2.3.4.0709")]
|
||||
|
|
|
|||
11
TShockAPI/Resources.Designer.cs
generated
11
TShockAPI/Resources.Designer.cs
generated
|
|
@ -1,7 +1,7 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.1
|
||||
// Runtime Version:4.0.30319.235
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
|
|
@ -91,15 +91,6 @@ namespace TShockAPI {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
/// ¡¢£¤¥¦§¨©.
|
||||
/// </summary>
|
||||
internal static string mousefontchars {
|
||||
get {
|
||||
return ResourceManager.GetString("mousefontchars", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to #format
|
||||
///#ip group
|
||||
|
|
|
|||
|
|
@ -124,9 +124,6 @@
|
|||
<data name="itembans" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>config\itembans.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
|
||||
</data>
|
||||
<data name="mousefontchars" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>config\mousefontchars.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
|
||||
</data>
|
||||
<data name="users" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>config\users.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
|
||||
</data>
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ using System.Reflection;
|
|||
using System.Threading;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Content;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
using TerrariaAPI;
|
||||
using TerrariaAPI.Hooks;
|
||||
|
|
@ -105,7 +106,7 @@ namespace TShockAPI
|
|||
NetHooks.GetData += GetData;
|
||||
NetHooks.GreetPlayer += OnGreetPlayer;
|
||||
NpcHooks.StrikeNpc += NpcHooks_OnStrikeNpc;
|
||||
|
||||
|
||||
|
||||
Bans.LoadBans();
|
||||
GetDataHandlers.InitGetDataHandler();
|
||||
|
|
@ -113,7 +114,7 @@ namespace TShockAPI
|
|||
RegionManager.ReadAllSettings();
|
||||
WarpsManager.ReadAllSettings();
|
||||
ItemManager.LoadBans();
|
||||
RconHandler.StartThread();
|
||||
//RconHandler.StartThread();
|
||||
|
||||
Log.ConsoleInfo("AutoSave " + (TShock.Config.AutoSave ? "Enabled" : "Disabled"));
|
||||
Log.ConsoleInfo("Backups " + (Backups.Interval > 0 ? "Enabled" : "Disabled"));
|
||||
|
|
@ -277,7 +278,7 @@ namespace TShockAPI
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (!FileTools.OnWhitelist(player.IP))
|
||||
{
|
||||
|
|
@ -288,7 +289,7 @@ namespace TShockAPI
|
|||
|
||||
Players[ply] = player;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void OnLeave(int ply)
|
||||
|
|
@ -319,14 +320,11 @@ namespace TShockAPI
|
|||
return;
|
||||
}
|
||||
|
||||
foreach (var character in text)
|
||||
if (!Tools.ValidString(text))
|
||||
{
|
||||
if (Resources.mousefontchars.IndexOf(character) == -1)
|
||||
{
|
||||
Tools.HandleCheater(tsplr, "Attempted to crash clients");
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
Tools.Kick(tsplr, "Unprintable character in chat");
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (msg.whoAmI != ply)
|
||||
|
|
|
|||
|
|
@ -135,7 +135,6 @@
|
|||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="config\mousefontchars.txt" />
|
||||
<Content Include="config\itembans.txt" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
|
|
@ -148,7 +147,7 @@
|
|||
</PropertyGroup>
|
||||
<ProjectExtensions>
|
||||
<VisualStudio>
|
||||
<UserProperties BuildVersion_IncrementBeforeBuild="False" BuildVersion_StartDate="2011/6/17" BuildVersion_BuildVersioningStyle="None.None.None.MonthAndDayStamp" BuildVersion_BuildAction="Both" BuildVersion_UpdateFileVersion="True" BuildVersion_UpdateAssemblyVersion="True" />
|
||||
<UserProperties BuildVersion_UpdateAssemblyVersion="True" BuildVersion_UpdateFileVersion="True" BuildVersion_BuildAction="Both" BuildVersion_BuildVersioningStyle="None.None.None.MonthAndDayStamp" BuildVersion_StartDate="2011/6/17" BuildVersion_IncrementBeforeBuild="False" />
|
||||
</VisualStudio>
|
||||
</ProjectExtensions>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
|
|
|||
|
|
@ -659,5 +659,20 @@ namespace TShockAPI
|
|||
return bytes.Aggregate("", (s, b) => s + b.ToString("X2"));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the string contains any unprintable characters
|
||||
/// </summary>
|
||||
/// <param name="str">String to check</param>
|
||||
/// <returns>True if the string only contains printable characters</returns>
|
||||
public static bool ValidString(string str)
|
||||
{
|
||||
foreach (var c in str)
|
||||
{
|
||||
if (c < 0x20 || c > 0xA9)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1 +0,0 @@
|
|||
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
¡¢£¤¥¦§¨©
|
||||
Loading…
Add table
Add a link
Reference in a new issue