From 93db840bec4669e6a63c7918992f8a66eedb9a5d Mon Sep 17 00:00:00 2001 From: Amber Kortier Date: Sat, 27 Jul 2024 15:06:00 +0200 Subject: [PATCH] Url Check --- .../PettableDatabase/PettableNameDatabase.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/PetNicknames/PetNicknames/PettableDatabase/PettableNameDatabase.cs b/PetNicknames/PetNicknames/PettableDatabase/PettableNameDatabase.cs index 56c2f4a..f5eba98 100644 --- a/PetNicknames/PetNicknames/PettableDatabase/PettableNameDatabase.cs +++ b/PetNicknames/PetNicknames/PettableDatabase/PettableNameDatabase.cs @@ -3,6 +3,8 @@ using PN.S; using System.Collections.Generic; using System.Linq; +using System.Text.RegularExpressions; +using static FFXIVClientStructs.FFXIV.Client.Graphics.Kernel.VertexShader; namespace PetRenamer.PetNicknames.PettableDatabase; @@ -124,6 +126,12 @@ void SetDirty() { if (name.IsNullOrWhitespace()) return null; + try + { + name = urlRegex.Replace(name, string.Empty); + } + catch { } + if (name.Length > PluginConstants.ffxivNameSize) { name = name.Substring(0, PluginConstants.ffxivNameSize); @@ -136,4 +144,9 @@ void SetDirty() return name; } + + readonly Regex urlRegex = new Regex( + @"\b(?:(?:https?|ftp):\/\/)?(?:(?:[a-z0-9\-]+\.)+[a-z]{2,}|localhost)(?::\d{1,5})?(?:\/[^\s]*)?\b", + RegexOptions.Compiled | RegexOptions.IgnoreCase + ); }