jenkinsci / hipchat-plugin

HipChat notification plugin for Jenkins
https://plugins.jenkins.io/hipchat/
54 stars 85 forks source link

Using macro expressions breaks HTML #98

Closed jakub-bochenski closed 7 years ago

jakub-bochenski commented 7 years ago

We use https://wiki.jenkins-ci.org/display/JENKINS/OWASP+Markup+Formatter+Plugin which allows to set build and job descriptions in HTML.

Unfortunately using an expression like $JOB_DESCRIPTION for a job with description

<h4>Reports unmerged commits</h4>

results in literal output

\

Reports unmerged commits\

on hipchat.

I'd expect the html tags to be interpreted instead of escaped.

aldaris commented 7 years ago

Which field of the notification message are we talking about? Do you have cards enabled? In case of cards, the body of the notification text (the one you see after dropdown) does not appear to support HTML elements at all.

jakub-bochenski commented 7 years ago

I am using cards, however setting a message like this

<a href="$URL"><strong>$JOB_DISPLAY_NAME</strong> #$BUILD_NUMBER</a> <i>$CHANGES_OR_CAUSE</i> <br> $JOB_DESCRIPTION

results in a, strong, etc. tags being interpreted with only h4 from $JOB_DESCRIPTION is passed literally

snap

aldaris commented 7 years ago

This is sadly not a plugin issue, sending the below JSON as a notification resulted in the same behavior:

{
 "message": "foobar",
 "card": {
  "style": "application",
  "description": {
   "value": "Description",
   "format": "html"
  },
  "format": "medium",
  "url": "http://localhost:8080/jenkins",
  "title": "Title",
  "activity": {
   "html": "Activity HTML <a href=\"http://localhost:8080\">link</a> <i>italic</i> <strong>STRONG</strong> <h4>header4</h4>"
  },
  "id": "foo-bar"
 }
}

It looks like HipChat does not like the h4 tag in the activity/html JSON field.