Skip to content

templates: seven more authored strings still land verbatim in a Java string literal after #7262, and the escape helper keeps multiplying (#7241 follow-up) #7295

Description

@delchev

Describe the bug

PR #7262 (#7241) routes the four message families the issue named (checks, guards, unique, refuse) through JavaLiterals.escape, and its body says: "Every other authored string the templates write into a Java string literal was still interpolated verbatim". That sentence is still true after the PR for these sites (all verified on origin/master):

authored source template site
entity label: pattern literal segments (EdmIntentGenerator.java:3164) template-application-dao-java/data/Repository.java.template:1356 label.append("${part.text}"); (+ :1359,1365 "${part.format}")
setField step value: (GlueIntentGenerator.java:5008) template-application-events-java/events/SetField.java.template:44 updateProperty(..., "${field}", "${value}")
report parameter initial: (ReportIntentGenerator.java:1154) data/reportFileEntity.java.template:199 value(filter, "${parameter.name}", "${parameter.initial}")
field description: (EdmIntentGenerator.java:1233) data/Entity.java.template:38 @Documentation("${property.description}")
number: { series: ... } name (free text, no shape check) Repository.java.template:409,411 DocumentNumbers.next("${property.numberSeries}", ...); events/Numbering.java.template:49,52,56
seeded status names joined id=name, (EdmIntentGenerator.java:2538) Repository.java.template:942 "${lifecycleStatusNames}".split(",") - a ", \ or , in a status name breaks the literal or the split
cron, destination, path (authored, identifier-ish but unvalidated) Job.java.template:47, InboundFile.java.template:63, InboundMessage.java.template:44, Outbound.java.template:85, Webhook.java.template:48

A description: Customer's "trade" name, a setField value with a quote, a report initial: O'Neil or a label pattern literal " each fail javac for the whole generated module with the message #7241 described - or, for the status-name join, silently mis-parse.

And the helper itself keeps multiplying instead of being shared: JavaLiterals.escape now has three template-facing callers while the identical loop is hand-rolled in PostSetSupport.escape (#7268), ModelParameterProcessor.java:1331 (widgetPatternJava), GlueIntentGenerator.java:3008/3375/3485/2746, IntegrationSupport.java:74, NotificationSupport.java:345, ScheduleSupport, plus JsonLiterals / JsLiterals (#7254, #7255).

Expected

  • The sites above render through the one escape (or, for cron / destination / path / series, are shape-checked at parse so they can never contain a quote).
  • One escape for Java string literals, reachable from ide-template and engine-intent; the hand-rolled copies replaced.
  • IntentEmissionCoverageIT's fixture carries a quote in a description, a setField value and a report initial, so the generated module is compiled with them.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions