diff --git a/Plugins/RynthCore.Plugin.RynthDreamWeave/DreamWeave/LaunchWire.cs b/Plugins/RynthCore.Plugin.RynthDreamWeave/DreamWeave/LaunchWire.cs index 90b2e20..b0fea6d 100644 --- a/Plugins/RynthCore.Plugin.RynthDreamWeave/DreamWeave/LaunchWire.cs +++ b/Plugins/RynthCore.Plugin.RynthDreamWeave/DreamWeave/LaunchWire.cs @@ -13,6 +13,8 @@ internal static class LaunchWire public const string RequestCommand = "/weblogin"; public const string ReplyLead = "[WEB] "; public const string SuccessLead = "[WEB] Launch code: "; + /// Any line starting like this has the success shape: malformed, it is dropped, never shown as a refusal. + private const string SuccessStem = "[WEB] Launch code"; public const int CodeLength = 43; public const long ReplyTimeoutMs = 10_000, MinIntervalMs = 3_000; @@ -37,8 +39,9 @@ internal static class LaunchWire int start = ChatSource.ContentStart(text); ReadOnlySpan line = text.AsSpan(start); - if (line.StartsWith(SuccessLead.AsSpan(), StringComparison.Ordinal)) + if (line.StartsWith(SuccessStem.AsSpan(), StringComparison.Ordinal)) { + if (!line.StartsWith(SuccessLead.AsSpan(), StringComparison.Ordinal)) return false; ReadOnlySpan rest = line.Slice(SuccessLead.Length); if (rest.Length <= CodeLength || rest[CodeLength] != ' ') return false; for (int i = 0; i < CodeLength; i++) diff --git a/Plugins/RynthCore.Plugin.RynthDreamWeave/RynthCore.Plugin.RynthDreamWeave.csproj b/Plugins/RynthCore.Plugin.RynthDreamWeave/RynthCore.Plugin.RynthDreamWeave.csproj index a80a980..854d7fe 100644 --- a/Plugins/RynthCore.Plugin.RynthDreamWeave/RynthCore.Plugin.RynthDreamWeave.csproj +++ b/Plugins/RynthCore.Plugin.RynthDreamWeave/RynthCore.Plugin.RynthDreamWeave.csproj @@ -13,6 +13,11 @@ DreamWeave only: the server card (rules, server features, player commands, links, account setup) in its own window on the RynthCore bar, the retail Character panel whose XP for next level keeps reading past level 275, and the bank check every minute that gives Lum/hr its luminance. + + + + + diff --git a/Tools/RynthServerPack.Tests/DreamWeaveWebTests.cs b/Tools/RynthServerPack.Tests/DreamWeaveWebTests.cs index eeb81b1..509412a 100644 --- a/Tools/RynthServerPack.Tests/DreamWeaveWebTests.cs +++ b/Tools/RynthServerPack.Tests/DreamWeaveWebTests.cs @@ -17,6 +17,7 @@ internal static class DreamWeaveWebTests r.Add("dreamweave web: a player's copy of the launch line is never taken", PlayerCopy); r.Add("dreamweave web: the launch URL is built from constants and a clean code", UrlFromConstants); r.Add("dreamweave web: destination ids are verbs no one else uses", IdsAreFree); + r.Add("dreamweave web: LaunchWire: code alphabet is strict", Alphabet); r.Add("dreamweave web: ACE's refusals parse as refusals, other lines are ignored", Refusals); } @@ -92,6 +93,44 @@ internal static class DreamWeaveWebTests } } + private static void Alphabet() + { + const string b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"; + Check.Eq(b64.Length, 64, "64 base64url chars"); + foreach (char c in b64) + Check.True(LaunchWire.IsCodeChar(c), "accepted: " + c); + + char[] bad = { '+', '/', '=', '&', '?', '#', '%', '.', ' ', '\t', '!', '~', '\u00e9', '\u0000' }; + foreach (char c in bad) + { + string name = "U+" + ((int)c).ToString("X4"); + Check.True(!LaunchWire.IsCodeChar(c), "IsCodeChar rejects " + name); + foreach (int idx in new[] { 0, 21, 42 }) + { + char[] chars = Code.ToCharArray(); + chars[idx] = c; + string line = "[WEB] Launch code: " + new string(chars) + " (single use, expires in 60 seconds)"; + Check.True(!Parse(line, 0x05, out string code, out string refusal), "refused: " + name + " at " + idx); + Check.Eq(code, "", "no code: " + name + " at " + idx); + Check.Eq(refusal, "", "no refusal: " + name + " at " + idx); + } + } + + // Round trip of a code holding both '-' and '_'. + string dashed = "-_" + Code.Substring(2); + Check.True(Parse("[WEB] Launch code: " + dashed + " (single use, expires in 60 seconds)", 0x05, out string got, out _), "dash/underscore code parses"); + Check.Eq(got, dashed, "dash/underscore code intact"); + Check.True(DreamWeaveWeb.LaunchUrl(got, DreamWeaveWeb.ById("market")!).Contains("code=" + dashed + "&to=", StringComparison.Ordinal), "url carries the code verbatim"); + + // The stem alone marks the success shape: malformed, it is dropped, never a refusal. + foreach (string l in new[] { "[WEB] Launch code:" + Code, "[WEB] Launch code " + Code, "[WEB] Launch code", "[WEB] Launch codes " + Code }) + { + Check.True(!Parse(l, 0x05, out string c2, out string r2), "malformed success-shaped line dropped: " + l); + Check.Eq(c2, "", "no code: " + l); + Check.Eq(r2, "", "no refusal text: " + l); + } + } + private static void Refusals() { string[] lines =