From 484f0837e8cf5f4e7a97260bdc95ad9cb80c7309 Mon Sep 17 00:00:00 2001 From: Tomas Bjerre Date: Thu, 11 Aug 2016 19:37:39 +0200 Subject: [PATCH] Preventing Javascript * Preventing Javascript from being executed when added to fields in admin view. * Also found that if several notifications were triggered by a button only first would trigger if it failed without response. Also logging were broken in this case. --- CHANGELOG.md | 15 ++++++++++++++- src/main/java/se/bjurr/prnfb/http/UrlInvoker.java | 10 ++++++++-- .../prnfb/transformer/ButtonTransformer.java | 11 ++++++++--- src/main/resources/pr-triggerbutton.js | 10 +++++----- src/main/resources/utils.js | 8 +++++--- 5 files changed, 40 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 008bb377..eb212b2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,10 +3,23 @@ Changelog of Pull Request Notifier for Bitbucket. ## Unreleased +### GitHub [#132](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/issues/132) How to trigger Jenkins 2.1 with parameters + Better documenting how to trigger Jenkins + + [fe0d68fed224d5e](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/commit/fe0d68fed224d5e) Tomas Bjerre *2016-07-31 19:37:11* + +### No issue + Preventing Javascript + + * Preventing Javascript from being executed when added to fields in admin view. + + [1bf663392161c2d](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/commit/1bf663392161c2d) Tomas Bjerre *2016-08-11 17:38:18* + +## 2.34 ### GitHub [#137](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/issues/137) Triigger build button appears in the merged PR view too. Adding PULL_REQUEST_STATE variable - [064030fe3420fe0](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/commit/064030fe3420fe0) Tomas Bjerre *2016-07-30 08:48:07* + [2455b339fceebf4](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/commit/2455b339fceebf4) Tomas Bjerre *2016-07-30 08:49:20* ## 2.33 ### GitHub [#134](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/issues/134) Not able to see PR buttons diff --git a/src/main/java/se/bjurr/prnfb/http/UrlInvoker.java b/src/main/java/se/bjurr/prnfb/http/UrlInvoker.java index dfe41ebf..60ee8586 100644 --- a/src/main/java/se/bjurr/prnfb/http/UrlInvoker.java +++ b/src/main/java/se/bjurr/prnfb/http/UrlInvoker.java @@ -161,7 +161,11 @@ public HttpResponse invoke() { configureProxy(builder); this.response = doInvoke(httpRequestBase, builder); - LOG.debug(this.response.getContent()); + if (LOG.isDebugEnabled()) { + if (this.response != null) { + LOG.debug(this.response.getContent()); + } + } return this.response; } @@ -346,7 +350,9 @@ HttpResponse doInvoke(HttpRequestBase httpRequestBase, HttpClientBuilder builder LOG.error("", e); } finally { try { - httpResponse.close(); + if (httpResponse != null) { + httpResponse.close(); + } } catch (IOException e) { propagate(e); } diff --git a/src/main/java/se/bjurr/prnfb/transformer/ButtonTransformer.java b/src/main/java/se/bjurr/prnfb/transformer/ButtonTransformer.java index 600a5edc..4450f3b4 100644 --- a/src/main/java/se/bjurr/prnfb/transformer/ButtonTransformer.java +++ b/src/main/java/se/bjurr/prnfb/transformer/ButtonTransformer.java @@ -46,11 +46,16 @@ public static PrnfbButton toPrnfbButton(ButtonDTO buttonDto) { public static ButtonPressDTO toTriggerResultDto(PrnfbButton button, List results) { List notificationResponses = newArrayList(); for (NotificationResponse from : results) { - String content = from.getHttpResponse().getContent(); - int status = from.getHttpResponse().getStatus(); + String content = null; + int status = 0; + URI uri = null; + if (from.getHttpResponse() != null) { + content = from.getHttpResponse().getContent(); + status = from.getHttpResponse().getStatus(); + uri = from.getHttpResponse().getUri(); + } UUID notification = from.getNotification(); String notificationName = from.getNotificationName(); - URI uri = from.getHttpResponse().getUri(); notificationResponses.add(new NotificationResponseDTO(uri, content, status, notification, notificationName)); } return new ButtonPressDTO(button.getConfirmation(), notificationResponses); diff --git a/src/main/resources/pr-triggerbutton.js b/src/main/resources/pr-triggerbutton.js index 48c79b29..a30d741e 100644 --- a/src/main/resources/pr-triggerbutton.js +++ b/src/main/resources/pr-triggerbutton.js @@ -23,16 +23,16 @@ define('plugin/prnfb/pr-triggerbutton', [ AJS.flag({ close: 'auto', type: 'success', - title: notificationResponse.notificationName, + title: notificationResponse.notificationName.replace(/