Skip to content

fix: use quote-aware tag close detection in FAST parser plugin#242

Merged
janechu merged 1 commit intomainfrom
fix/fast-template-gt-operator
Apr 16, 2026
Merged

fix: use quote-aware tag close detection in FAST parser plugin#242
janechu merged 1 commit intomainfrom
fix/fast-template-gt-operator

Conversation

@janechu
Copy link
Copy Markdown
Contributor

@janechu janechu commented Apr 15, 2026

Description

Fix malformed <f-template> output when condition expressions contain > or >= operators.

When converting <if condition="vara > 2"> to <f-when value="{{vara > 2}}">, the naive tag_str.find('>') call matches the > inside the quoted attribute value instead of the actual tag-closing bracket. This produces malformed output with mismatched tags: <if condition="vara > 2">Over two</f-when>.

The fix introduces find_tag_close() — a quote-aware scanner that skips > characters inside double-quoted attribute values. All tag-closing searches in the FAST parser plugin (convert_if_tag, convert_for_tag, convert_route_tag, convert_complex_attrs, strip_shadowrootmode) now use this function.

Test Plan

  • Added regression tests for >, >=, and < operators in convert_btr_to_fast()
  • Added unit test for find_tag_close() with quoted > characters
  • All 289 parser tests pass
  • cargo xtask check passes (license-headers, fmt, clippy, test)

Checklist

  • I have added tests for my changes.
  • I have tested my changes.
  • I have updated the project documentation to reflect my changes.
  • I understand and have considered the performance impact of my changes.

@janechu janechu marked this pull request as ready for review April 16, 2026 03:17
@janechu janechu force-pushed the fix/fast-template-gt-operator branch from e99221e to 1684126 Compare April 16, 2026 03:19
When condition expressions contain `>` or `>=` operators (e.g.,
`<if condition="vara > 2">`), the naive `tag_str.find('>')` matches
the `>` inside the quoted attribute value instead of the actual tag
closing bracket. This causes the conversion to produce malformed
`<f-template>` output with mismatched `<if condition=...></f-when>` tags.

Replace all `tag_str.find('>')` calls with `find_tag_close()` that
skips `>` characters inside double-quoted attribute values.

Co-authored-by: Copilot <[email protected]>
@janechu janechu force-pushed the fix/fast-template-gt-operator branch from 1684126 to abf8c8d Compare April 16, 2026 04:15
@janechu janechu merged commit 681587d into main Apr 16, 2026
21 checks passed
@janechu janechu deleted the fix/fast-template-gt-operator branch April 16, 2026 04:20
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