Skip to content

fix(logic): chat length limit logic - #51

Merged
Rushaway merged 4 commits into
masterfrom
Rushaway-patch-1
Feb 23, 2026
Merged

fix(logic): chat length limit logic#51
Rushaway merged 4 commits into
masterfrom
Rushaway-patch-1

Conversation

@Rushaway

@Rushaway Rushaway commented Feb 21, 2026

Copy link
Copy Markdown
Member

PR Description

Summary

  • Fixes chat overflow exceptions caused by oversized ConnectAnnounce messages.
  • Safely truncates output to chat limits.
  • Adds short user-facing notices when a join message is truncated or skipped.

What changed

  • Remove format-token neutralization
  • Updated warning texts with concise call-to-action (sm_joinmsg).
  • Refactored announce truncation logic to be explicit and readable:
    • truncate base announcement if needed
    • append join message only when space is available
    • truncate appended join message when necessary

Why

  • Prevents runtime SayText2 overflow errors.
  • Keeps behavior predictable for long historical/custom messages.

User impact

  • No more error DLL_MessageEnd: Refusing to send user message SayText2 of 256 bytes to client, user message size limit is 255 bytes
  • Players are informed when their custom message is truncated/skipped and how to fix it.

Testing

  • Manually validated long join-message scenarios: append, truncate, and skip paths.

Copilot AI review requested due to automatic review settings February 21, 2026 14:30

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses Source engine chat overflow (SayText2) issues in ConnectAnnounce by sanitizing stored/per-user join messages and enforcing a safe length cap when building the final announcement string.

Changes:

  • Added SanitizeClientJoinMessage() and applied it when loading join messages from local KeyValues and SQL (with a lazy “sanitize then persist” migration).
  • Introduced explicit truncation/skip logic to keep the final SayText2 output under a fixed length budget, with user-facing notices.
  • Bumped plugin version to 2.5.6 and added a MAX_SAYTEXT2_LENGTH constant.
Comments suppressed due to low confidence (1)

addons/sourcemod/scripting/ConnectAnnounce.sp:1413

  • CPrintToChat* treats the first string parameter as a format string. Since sFinalMessage includes user-controlled content (e.g., {NAME} from GetClientName and potentially join messages), any % sequences can be interpreted as format specifiers and trigger runtime errors or be abused to spam errors. To avoid format-string injection, pass the message as a data parameter (e.g., use a constant format like %s and provide sFinalMessage as an argument), and/or ensure all % characters in inserted user content are escaped.
			Format(sFinalMessage, sizeof(sFinalMessage), "%s %s", sFinalMessage, sSafeJoinMessage);
		}
	}

	if (sendToAll)
		CPrintToChatAll(sFinalMessage);
	else
		CPrintToChat(client, sFinalMessage);

Comment thread addons/sourcemod/scripting/ConnectAnnounce.sp Outdated
Comment thread addons/sourcemod/scripting/ConnectAnnounce.sp Outdated
@Rushaway Rushaway changed the title fix(logic): sanitize joinmsg, chat length limit fix(logic): chat length limit logic Feb 23, 2026
@Rushaway
Rushaway merged commit ca02bcb into master Feb 23, 2026
3 checks passed
@Rushaway
Rushaway deleted the Rushaway-patch-1 branch February 23, 2026 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants