Skip to content

Harden directive/filter edge-case handling and add executable edge matrix coverage#3

Draft
Copilot wants to merge 6 commits into
copilot/refatoracao-arquitetural-view-enginefrom
copilot/refactoring
Draft

Harden directive/filter edge-case handling and add executable edge matrix coverage#3
Copilot wants to merge 6 commits into
copilot/refatoracao-arquitetural-view-enginefrom
copilot/refactoring

Conversation

Copy link
Copy Markdown

Copilot AI commented Jun 2, 2026

The engine still had edge-case failures in directive/filter parsing, especially around {{ ... }} expressions in attributes and filter chains containing literal pipes. This PR hardens lexer/compiler/filter behavior and adds a focused edge-case matrix to prevent regressions across directives and core filters.

  • Lexer tag extraction robustness

    • Lexer::extractTag now tracks mustache depth while scanning tags.
    • Prevents premature tag termination when > appears inside {{ ... }} (e.g. array syntax with => in <Include data={{ ... }}>).
  • Filter-chain parsing correctness

    • Compiler::compileExpression now uses a delimiter-aware splitter for |.
    • Pipes inside quoted strings/parenthesized args no longer split filters incorrectly (e.g. join(" | ")).
  • String/array filter hardening

    • StringFilters: safer UTF-8-aware truncation helpers with non-mbstring fallbacks.
    • FilterRegistry::reverse: multibyte-safe string reverse when mb_* is available.
    • ArrayFilters::join: stable handling for non-scalar elements via deterministic stringification.
    • ArrayFilters::json: partial-output mode to avoid hard failures on non-encodable segments.
  • Edge-case matrix for directives + filters

    • Added examples/edge_matrix.php with executable scenarios covering:
      • If/ElseIf/Else, Foreach loop metadata, Set, Include with expression data, Block
      • UTF-8 string filters, numeric/date filters, array filters, chained filters with argument edge cases
  • Docs

    • README now includes the edge-matrix command in the quick validation section.
// Previously fragile: '|' inside filter args could be split as another filter
{{ value | join(" | ") }}

// Now parsed correctly as one filter call with one argument.

Copilot AI changed the title refactor: drop Beobles\ namespace prefix + round-2 bug/security fixes fix(Renderer): prevent Apache mod_php output from triggering false SyntaxException Jun 2, 2026
Copilot AI requested a review from beobles June 2, 2026 23:19
Copilot AI changed the title fix(Renderer): prevent Apache mod_php output from triggering false SyntaxException Harden template lint execution and make string filters UTF-8 safe Jun 2, 2026
Copilot AI changed the title Harden template lint execution and make string filters UTF-8 safe Harden directive/filter edge-case handling and add executable edge matrix coverage Jun 2, 2026
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