From 3bca836051ac2a577ccd14a20c6c0e4adedf50c0 Mon Sep 17 00:00:00 2001 From: SilverFire - Dmitry Naumenko Date: Wed, 20 Feb 2019 12:29:40 +0000 Subject: [PATCH] Add CSRF token to "Run query" link, enhanced JSON formatting --- src/views/debug/detail.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/views/debug/detail.php b/src/views/debug/detail.php index 1895637..6494d05 100644 --- a/src/views/debug/detail.php +++ b/src/views/debug/detail.php @@ -12,7 +12,7 @@ CSS ); -$this->registerJs(<<registerJs(<<<'JS' function syntaxHighlight(json) { json = json.replace(/&/g, '&').replace(//g, '>'); return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) { @@ -42,8 +42,11 @@ function syntaxHighlight(json) { $.ajax({ type: 'POST', url: $(this).attr('href'), + beforeSend: function(xhr) { + xhr.setRequestHeader('X-CSRF-Token', $('meta[name=csrf-token]').attr('content')) + }, success: function (data, status, xhr) { - result.find('.result').html( syntaxHighlight( JSON.stringify( data.result, undefined, 10) ) ); + result.find('.result').html($('
').html(syntaxHighlight(JSON.stringify( data.result, undefined, 2))));
                 result.find('.time').html(data.time);
             },
             error: function (jqXHR, textStatus, errorThrown) {
@@ -74,7 +77,7 @@ function syntaxHighlight(json) {
                 getDuration() ?>
                 
                     getMethod() ?> getUrlEncoded() ?>
-

getBodyEncoded() ?>

+

getBodyEncoded() ?>

getTrace() ?>