From 555acacd6d7b44093b4d756df9a50d129a33b690 Mon Sep 17 00:00:00 2001 From: thuck Date: Tue, 7 Mar 2017 23:29:16 +0100 Subject: [PATCH] Validate query to avoid self-reference of variable #7614 --- public/app/features/templating/editor_ctrl.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/public/app/features/templating/editor_ctrl.ts b/public/app/features/templating/editor_ctrl.ts index 7bd745bed53..002afa4264b 100644 --- a/public/app/features/templating/editor_ctrl.ts +++ b/public/app/features/templating/editor_ctrl.ts @@ -77,6 +77,11 @@ export class VariableEditorCtrl { return false; } + if ($scope.current.type === 'query' && $scope.current.query.match(new RegExp('\\$' + $scope.current.name))) { + $scope.appEvent('alert-warning', ['Validation', 'Query contains variable self-reference']); + return false; + } + return true; };