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

Adapt to Token Macro's new escapeHtml parameter #157

Merged
merged 2 commits into from
May 6, 2022

Conversation

rsandell
Copy link
Member

See jenkinsci/token-macro-plugin#118

Also added help documentation for the token macro.

  • 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

pom.xml Outdated Show resolved Hide resolved
@rsandell rsandell requested a review from dwnusbaum April 22, 2022 13:51
Copy link
Member

@dwnusbaum dwnusbaum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really familiar with the plugin, so I added a couple of questions.

pom.xml Outdated
Comment on lines 341 to 346
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>2.2</version>
<!--<version>2.2</version>-->
<scope>test</scope>
</dependency>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I think this dependency already comes in transitively from jenkins-test-harness at this version. Can it be deleted?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, I just forgot to remove it after all my back and forth testing what I need to do to make the require upper bounds to be gone :)

pom.xml Outdated
<dependency>
<groupId>org.jenkins-ci.main</groupId>
<artifactId>jenkins-test-harness</artifactId>
<version>1736.vc72c458c5103</version>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Could the parent pom be updated instead? Also for what it's worth you can set the property <jenkins-test-harness.version> without having to declare the whole dependency.

@@ -133,7 +146,11 @@ public String render(FailureCauseBuildAction action) {
final FailureCauseDisplayData data = action.getFailureCauseDisplayData();
if (data.getFoundFailureCauses().isEmpty() && data.getDownstreamFailureCauses().isEmpty()) {
logger.info("there were no causes");
return noFailureText;
if (!useHtmlFormat && escapeHtml) {
Copy link
Member

@dwnusbaum dwnusbaum Apr 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to use !useHtmlFormat || escapeHtml instead? Or maybe get rid of escapeHtml completely and just use useHtmlFormat to control escaping? Or in other words, if I set escapeHtml to true, would it make sense to set useHtmlFormat to true? Or would that be a pointless configuration? Same for setting escapeHtml to false and useHtmlFormat to false, would that be redundant?

(Maybe I'm just confused about the name useHtmlFormat.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

escapeHtml is the parameter that I can't get rid of, it's now inherited from the parent class. useHtmlFormat is the one that has always been there and if it is true it will escape all relevant parts and always has. So the "new" parameter is then only relevant if the user wants a non html formatted list.

@@ -297,9 +318,17 @@ private void addIndicationRepresentation(final StringBuilder stringBuilder,
stringBuilder.append(":\n");
stringBuilder.append(indentForDepth(indentLevel));
stringBuilder.append(LIST_BULLET_SPACE);
stringBuilder.append("<");
if (escapeHtml) {
stringBuilder.append("&lt;");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the plugin is adding this itself, is it always safe? Or can we not guarantee that? I'm confused about why we would emit &lt; here vs just not emitting anything.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am interpreting the situation as the user wants the text version of the output, but still want it to be safe html 🤷‍♂️

@rsandell rsandell added the bug label May 6, 2022
@rsandell rsandell merged commit 84ed11d into master May 6, 2022
@rsandell rsandell deleted the escapeHtmlTokenField branch May 6, 2022 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants