bneradt commented on code in PR #13587:
URL: https://github.com/apache/trafficserver/pull/13587#discussion_r4127410454
##########
tools/hrw4u/src/hrw_symbols.py:
##########
@@ -414,6 +415,20 @@ def negate_expression(self, term: str) -> str:
def percent_to_ident_or_func(self, percent: str, section: SectionType |
None) -> tuple[str, bool]:
"""Convert percent block to identifier or function call."""
+ stripped, mods = split_percent_mods(percent)
+ expr, is_func = self._percent_to_ident_or_func(stripped, section)
+
+ if not mods:
+ return expr, is_func
+
+ # A block with no DSL equivalent comes back as %{...}, where the
modifiers belong
+ # inside the braces rather than in a "with" clause.
+ if expr == stripped:
+ return apply_percent_mods(expr, mods), is_func
+
+ return f"{expr} with {','.join(mods)}", is_func
Review Comment:
[P2] Preserve interpolation syntax for normalized state assignments
This new return value also reaches the state/session-variable assignment
branch in `op_to_hrw4u()`, which inserts it directly after `=` rather than
wrapping it as an interpolation. For example, `set-state-int8 0
%{HEADER:X-Input [NORM]}` now converts to `int8_0 = inbound.req.X-Input with
NORM;`. The forward grammar does not accept a `with` clause on assignment
values, so the generated configuration cannot be compiled back to
header_rewrite. Please update that caller to emit `int8_0 =
"{inbound.req.X-Input with NORM}";` (and cover the state/session assignment
path with a round-trip test). I reproduced this with the current
`InverseSymbolResolver.op_to_hrw4u()`; the header-assignment path already emits
the correct quoted interpolation.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]