Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix generated gdsl code display names #674

Merged
merged 3 commits into from
Jul 18, 2023
Merged

Fix generated gdsl code display names #674

merged 3 commits into from
Jul 18, 2023

Conversation

mbxsuite
Copy link
Contributor

@mbxsuite mbxsuite commented Mar 8, 2023

Calling https://localhost/pipeline-syntax/gdsl creates a document that escapes forward slashes.

The use of groovy.json.StringEscapeUtils.escapeJavaScript(java.lang.String), will break parsing of the resulting content within an IDE (i.e. IntelliJ Idea), if described plugin steps have a forward slash in their displayName content.

plugin samples:

  • step envVarsForTool of plugin "pipeline-model-definition" (contains single quote) Link
  • step sshGet, sshPut of plugin "ssh-steps" (contain forward slash) Link

According to Groovy API doc of escapeJavaScript :

The only difference between Java strings and JavaScript strings is that in JavaScript, a single quote must be escaped.

which is not 100% true to their code, as it also escapes forward slashes, which in turn breaks the parsing.

So to have the displayName properly escaped, it is sufficient to switch to escapeJava(String) and also escape single quotes afterwards.

(Using escapeJavaStyleString(<String>, true, false) whould also be sufficient, but that worker function is marked private in groovy.json.StringEscapeUtils)

JENKINS-70755

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests - that demonstrates feature works or fixes the issue

@mbxsuite mbxsuite requested a review from a team as a code owner March 8, 2023 14:15
@jglick jglick added the bug label Jul 18, 2023
@jglick jglick enabled auto-merge July 18, 2023 23:16
@jglick jglick merged commit a180afe into jenkinsci:master Jul 18, 2023
12 of 13 checks passed
@mbxsuite mbxsuite deleted the fixGeneratedGdslCodeDisplayNames branch October 20, 2023 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants