Skip to content

Enhance command handling and validation across multiple commands REPOST #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

melihxz
Copy link

@melihxz melihxz commented Aug 17, 2025

  1. fixed the readFileLine function in utils.cpp:

    • Completely rewrote the logic to properly cycle through lines in a file
    • Added proper handling for empty files and lines
    • Used a vector to store all lines and modulo arithmetic for cycling
  2. Fixed the project command in project_cmd.cpp:

    • Removed the problematic button click handler registration that was causing issues
    • Improved index handling with modulo arithmetic
    • Added proper validation for empty project lists
  3. Updated main.cpp to handle project hint buttons properly:

    • Moved the button click handler logic from project_cmd.cpp to main.cpp
    • Added proper error handling for project file access
    • Added validation for project data and indices
  4. Fixed the close command in close_cmd.cpp:

    • Added proper permission checks for both thread and ticket closing
    • Improved error handling and user feedback
    • Fixed logic for closing tickets by properly removing user access
  5. Improved the rule command in rule_cmd.cpp:

    • Added better validation for command options
    • Improved error messages for invalid rule numbers
    • Added safer access to rule data
  6. Enhanced the ticket command in ticket_cmd.cpp:

    • Added check to prevent users from creating multiple tickets
    • Improved error handling with detailed error messages
    • Added proper validation before creating tickets
  7. Optimized the suggestion system in suggestion.cpp:

    • Added comprehensive error checking for all operations
    • Improved validation of message data before processing
    • Added better error messages for users
    • Fixed potential issues with reaction handling
  8. Updated the command structure in commands.h:

    • Fixed the function signature for command functions to use const references
    • Added missing include for

These changes fix several critical issues in the code:

  • logic errors in file reading that could cause undefined behavior
  • Memory and resource management issues
  • lack of proper error handling in several functions
  • Potential security issues with missing permission checks
  • inefficient algorithms for cycling through data
  • improper event handler registration that could cause memory leaks

The optimizations ive made improve:

  • code reliability and stability
  • performance through better algoritms
  • user experience with clearer error messages
  • security with proper permission checking
  • maintainability with cleaner code structure

discord : melihxz

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.

1 participant