Skip to content

Commit

Permalink
Allow only alphanumeric characters in plugin names
Browse files Browse the repository at this point in the history
  • Loading branch information
features-not-bugs committed Feb 22, 2023
1 parent c5899f5 commit f470953
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/RustServerMetrics/MetricsLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
using System.Linq;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using UnityEngine;

namespace RustServerMetrics
{
public class MetricsLogger : SingletonComponent<MetricsLogger>
{
const string CONFIGURATION_PATH = "HarmonyMods_Data/ServerMetrics/Configuration.json";
readonly static char[] PLUGIN_NAME_TRIMSTART = new char[] { '_' };
readonly static Regex PLUGIN_NAME_REGEX = new Regex(@"_|[^\w\d]");
readonly StringBuilder _stringBuilder = new();
readonly Dictionary<ulong, Action> _playerStatsActions = new();
readonly Dictionary<ulong, uint> _perfReportDelayCounter = new();
Expand Down Expand Up @@ -187,7 +188,7 @@ internal void OnOxidePluginMetrics(Dictionary<string, double> metrics)
UploadPacket("oxide_plugins", metric, (builder, report) =>
{
builder.Append(",plugin=\"");
builder.Append(report.Key.TrimStart(PLUGIN_NAME_TRIMSTART).Replace("\"", "\\\""));
builder.Append(PLUGIN_NAME_REGEX.Replace(report.Key, string.Empty));
builder.Append("\" hookTime=");
builder.Append(report.Value);
});
Expand Down

0 comments on commit f470953

Please sign in to comment.