Back to all reviewers

API input/output validation

hyprwm/Hyprland
Based on 2 comments
C++

Ensure robust parsing of API inputs and proper formatting of outputs to prevent parsing errors and unexpected behavior. API implementations must handle edge cases where command identifiers might appear within parameter values, and all output formats must properly escape special characters.

API C++

Reviewer Prompt

Ensure robust parsing of API inputs and proper formatting of outputs to prevent parsing errors and unexpected behavior. API implementations must handle edge cases where command identifiers might appear within parameter values, and all output formats must properly escape special characters.

For input parsing, avoid simple substring matching that could incorrectly identify commands within parameter data. For example, a command like /notify blah blah /decorations should be parsed as the /notify command with /decorations as part of the parameter string, not as a /decorations command.

For output formatting, always escape special characters in structured formats like JSON:

// Bad - missing escaping
result += std::format(R"#("{}",)#", current);

// Good - with proper escaping  
result += std::format(R"#("{}",)#", escapeJSONStrings(current));

This prevents client-side parsing failures when API responses contain quotes, newlines, or other special characters. Implement comprehensive input validation and output sanitization as fundamental requirements for all API endpoints.

2
Comments Analyzed
C++
Primary Language
API
Category

Source Discussions