From 06f4964015bdfd915af559e726b068f02bf06232 Mon Sep 17 00:00:00 2001 From: ziirish Date: Wed, 14 Sep 2016 09:06:00 +0200 Subject: [PATCH] fix: asynchronous expand path was not handled correctly --- burpui/templates/gerard.js | 4 +-- burpui/templates/js/settings.js | 43 ++++++++++++++++++--------------- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/burpui/templates/gerard.js b/burpui/templates/gerard.js index 8e879213..a7f21b4d 100644 --- a/burpui/templates/gerard.js +++ b/burpui/templates/gerard.js @@ -126,10 +126,10 @@ var errorsHandler = function(json) { } catch(err) { message = Array(); if (typeof(json.message) == 'string') { - message.push([2, json.message]); + message.push([NOTIF_ERROR, json.message]); } else { for (field in json.message) { - message.push([2, field+': '+json.message[field]]); + message.push([NOTIF_ERROR, field+': '+json.message[field]]); } } } diff --git a/burpui/templates/js/settings.js b/burpui/templates/js/settings.js index 820f8de4..2ea342be 100644 --- a/burpui/templates/js/settings.js +++ b/burpui/templates/js/settings.js @@ -351,26 +351,31 @@ app.controller('ConfigCtrl', ['$scope', '$http', '$scrollspy', function($scope, api = '{{ url_for("api.path_expander", server=server, source=conf) }}'; {% endif -%} $scope.inc_invalid = {}; - $.ajax({ - url: api, - type: 'GET', - data: {'path': path}, - headers: { 'X-From-UI': true }, - }) - .fail(myFail) - .done(function(data) { - /* The server answered correctly but some errors may have occurred server - * side so we display them */ - if (data.notif) { - notifAll(data.notif) - $scope.inc_invalid[index] = true; - } else if (data.result) { - $scope.paths[index] = []; - $.each(data.result, function(i, p) { - $scope.paths[index].push(p); - }); + $http.get( + api, + { + headers: { 'X-From-UI': true }, + params: { 'path': path }, + } + ).then( + function(response) { + data = response.data; + /* The server answered correctly but some errors may have occurred server + * side so we display them */ + if (data.notif) { + notifAll(data.notif) + $scope.inc_invalid[index] = true; + } else if (data.result) { + $scope.paths[index] = []; + $.each(data.result, function(i, p) { + $scope.paths[index].push(p); + }); + } + }, + function(response) { + errorsHandler(response.data); } - }); + ); }; $scope.getClientsList = function() { api = '{{ url_for("api.clients_list", server=server) }}';