From 97f06e362804aeeccf81514ddf3614b8bff9892e Mon Sep 17 00:00:00 2001 From: Sida Chen Date: Wed, 13 Mar 2019 14:35:57 -0400 Subject: [PATCH] Frontend service key name regex check - Name is checked in the create preshared key form - Edit friendly name keep prompting until user enters a key that passes regex --- static/directives/service-keys-manager.html | 4 ++-- static/js/directives/ui/service-keys-manager.js | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/static/directives/service-keys-manager.html b/static/directives/service-keys-manager.html index b1267daeb..c87e27660 100644 --- a/static/directives/service-keys-manager.html +++ b/static/directives/service-keys-manager.html @@ -316,9 +316,9 @@ - + - A friendly name for the key for later reference. + A friendly name for the key for later reference. Must match ^[\s a-zA-Z0-9\-_:/]*$. diff --git a/static/js/directives/ui/service-keys-manager.js b/static/js/directives/ui/service-keys-manager.js index 295aa2692..96f9c3959 100644 --- a/static/js/directives/ui/service-keys-manager.js +++ b/static/js/directives/ui/service-keys-manager.js @@ -102,6 +102,17 @@ angular.module('quay').directive('serviceKeysManager', function () { 'value': key.name || '', 'callback': function(value) { if (value != null) { + if (!value.match(/^[\s a-zA-Z0-9\-_:/]*$/)){ + bootbox.alert({ + 'message': 'Invalid friendly name: input does not match ^[\\s a-zA-Z0-9\-_:/]*$', + 'callback': function(){ + $scope.showChangeName(key) + } + }); + + return + } + var data = { 'name': value };