From d3aa4b8274ab24664d66d8ebb333acd31349e722 Mon Sep 17 00:00:00 2001 From: rainbow napkin Date: Fri, 2 May 2025 03:47:46 -0400 Subject: [PATCH] Added underscores and dashes to usernames --- src/validators/accountValidator.js | 14 ++++++++++++-- www/css/channel.css | 2 ++ www/js/channel/chatPostprocessor.js | 6 +++--- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/validators/accountValidator.js b/src/validators/accountValidator.js index 1e021a4..38f08b7 100644 --- a/src/validators/accountValidator.js +++ b/src/validators/accountValidator.js @@ -25,9 +25,19 @@ module.exports.user = function(field = 'user'){ [field]: { escape: true, trim: true, - isAlphanumeric: { - errorMessage: "Usernames must be alphanumeric." + //Caution: Nerd Rant + //isAlphanumerics only takes locale for the option flag in schemas for some reason... + matches: { + //See this is the shit I'm talking about, WHY IS THIS CALLED OPTIONS? IT SHOULD BE PATTERN + //OPTIONS IS SUPPOSED TO BE AN OBJECT THAT PASSES EXTRA VALUES THATS LITERALLY HOW EVERYTHING ELSE IN THIS FUCKING LIBRARY WORKS + //WHO FUCKING WROTE THIS SHIT!?!?!?!?! + //HOW IS THIS ACCEPTED ON ONE OF THE MOST WIDELY USED VALIDATION LIBRARIES ON THE WEB!??!?!?!!? + //IT'S NOT EVEN FUCKING DOCUMENTED ANYWHERE!!!!!!!!!!!! + //WEBDEVS, GET YOUR FUCKING SHIT TOGETHER, FUCK! + options: [/^[A-Za-z0-9-_]+$/], + errorMessage: "Usernames can only contain numbers, letters, underscores, and dashes." }, + //matches: /^[A-Za-z0-9-_]+$/, isLength: { options: { min: 1, diff --git a/www/css/channel.css b/www/css/channel.css index 138302b..2f18ea6 100644 --- a/www/css/channel.css +++ b/www/css/channel.css @@ -165,6 +165,7 @@ p.panel-head-element{ .chat-entry-username{ margin: auto 0.2em auto 0; + text-wrap: nowrap; } .chat-entry-body{ @@ -203,6 +204,7 @@ span.user-entry{ font-size: 1em; width: fit-content; user-select: none; + text-wrap: nowrap; } .whisper{ diff --git a/www/js/channel/chatPostprocessor.js b/www/js/channel/chatPostprocessor.js index e9c2518..818c533 100644 --- a/www/js/channel/chatPostprocessor.js +++ b/www/js/channel/chatPostprocessor.js @@ -73,11 +73,11 @@ class chatPostprocessor{ //Create an empty array to hold the body this.messageArray = []; - //Escape any sanatized char codes as we use .textContent for double-safety, and to prevent splitting of char codes - //Split string by word-boundries on words and non-word boundries around whitespace, with negative lookaheads to exclude file seperators so we don't split link placeholders + //Unescape any sanatized char codes as we use .textContent for double-safety, and to prevent splitting of char codes + //Split string by word-boundries on words and non-word boundries around whitespace, with negative lookaheads to exclude file seperators so we don't split link placeholders, and dashes so we dont split usernames and other things //Also split by any invisble whitespace as a crutch to handle mushed links/emotes //If we can one day figure out how to split non-repeating special chars instead of special chars with whitespace, that would be perf, unfortunately my brain hasn't rotted enough to understand regex like that just yet. - const splitString = utils.unescapeEntities(this.rawData.msg).split(/(? {