Repository: incubator-ranger Updated Branches: refs/heads/master 5aa812fa9 -> cc74ff2e9
RANGER-337 : Allow using of hyphen or space in first/last name field Signed-off-by: Velmurugan Periasamy <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/incubator-ranger/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ranger/commit/cc74ff2e Tree: http://git-wip-us.apache.org/repos/asf/incubator-ranger/tree/cc74ff2e Diff: http://git-wip-us.apache.org/repos/asf/incubator-ranger/diff/cc74ff2e Branch: refs/heads/master Commit: cc74ff2e91898faec40c77fe24f83ad09802c298 Parents: 5aa812f Author: Gautam Borad <[email protected]> Authored: Wed Mar 25 17:04:07 2015 +0530 Committer: Velmurugan Periasamy <[email protected]> Committed: Thu Mar 26 15:43:50 2015 -0400 ---------------------------------------------------------------------- .../src/main/webapp/scripts/models/VXPortalUser.js | 4 ++-- .../webapp/scripts/views/policies/RangerPolicyForm.js | 1 + .../main/webapp/scripts/views/reports/AuditLayout.js | 9 ++++++--- .../src/main/webapp/scripts/views/users/UserForm.js | 14 ++++++++------ .../src/main/webapp/templates/helpers/XAHelpers.js | 2 +- 5 files changed, 18 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/cc74ff2e/security-admin/src/main/webapp/scripts/models/VXPortalUser.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/models/VXPortalUser.js b/security-admin/src/main/webapp/scripts/models/VXPortalUser.js index 66fd364..f2962e6 100644 --- a/security-admin/src/main/webapp/scripts/models/VXPortalUser.js +++ b/security-admin/src/main/webapp/scripts/models/VXPortalUser.js @@ -50,14 +50,14 @@ define(function(require){ firstName : { type : 'Text', title : localization.tt("lbl.firstName")+' *', - validators : ['required',{type:'regexp',regexp:/^[a-z][a-z0-9]+$/i,message :'Please enter valid name'}], + validators : ['required',{type:'regexp',regexp:/^[a-zA-Z][a-z0-9- ]*[a-zA-Z0-9]+$/,message :'First name should start with alphabets & can have hyphen, space.'}], editorAttrs : { 'placeholder' : localization.tt("lbl.firstName")} }, lastName : { type : 'Text', title : localization.tt("lbl.lastName")+' *', - validators : ['required',{type:'regexp',regexp:/^[a-z][a-z0-9]+$/i,message :'Please enter valid name'}], + validators : [{type:'regexp',regexp:/^[a-zA-Z][a-z0-9- ]*[a-zA-Z0-9]+$/,message :'Last name should start with alphabets & can have hyphen, space.'}], editorAttrs : { 'placeholder' : localization.tt("lbl.lastName")} }, emailAddress : { http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/cc74ff2e/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyForm.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyForm.js b/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyForm.js index fd567e8..aa88578 100644 --- a/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyForm.js +++ b/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyForm.js @@ -416,6 +416,7 @@ define(function(require){ callback(data); }, createSearchChoice: function(term, data) { + term = _.escape(term); if ($(data).filter(function() { return this.text.localeCompare(term) === 0; }).length === 0) { http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/cc74ff2e/security-admin/src/main/webapp/scripts/views/reports/AuditLayout.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/views/reports/AuditLayout.js b/security-admin/src/main/webapp/scripts/views/reports/AuditLayout.js index 78798e4..26375d8 100644 --- a/security-admin/src/main/webapp/scripts/views/reports/AuditLayout.js +++ b/security-admin/src/main/webapp/scripts/views/reports/AuditLayout.js @@ -622,7 +622,7 @@ define(function(require) { formatter: _.extend({}, Backgrid.CellFormatter.prototype, { fromRaw: function (rawValue, model) { rawValue = model.get('objectClassType'); - var action = model.get('action'), name = model.get('objectName'), + var action = model.get('action'), name = _.escape(model.get('objectName')), label = XAUtils.enumValueToLabel(XAEnums.ClassTypes,rawValue), html = ''; if(rawValue == XAEnums.ClassTypes.CLASS_TYPE_XA_ASSET.value || rawValue == XAEnums.ClassTypes.CLASS_TYPE_RANGER_SERVICE.value) html = 'Repository '+action+'d '+'<b>'+name+'</b>'; @@ -824,8 +824,9 @@ define(function(require) { var repoType = model.get('repoType'); that.serviceDefList.each(function(m){ if(parseInt(repoType) == m.id){ + rawValue = _.escape(rawValue); html = '<div title="'+rawValue+'">'+rawValue+'</div>\ - <div title="'+rawValue+'" style="border-top: 1px solid #ddd;">'+m.get('name')+'</div>'; + <div title="'+rawValue+'" style="border-top: 1px solid #ddd;">'+_.escape(m.get('name'))+'</div>'; return ; } }); @@ -842,6 +843,7 @@ define(function(require) { editable:false, formatter: _.extend({}, Backgrid.CellFormatter.prototype, { fromRaw: function (rawValue) { + rawValue = _.escape(rawValue); return _.isUndefined(rawValue) ? '--': '<span title="'+rawValue+'">'+rawValue+'</span>'; } }) @@ -995,7 +997,7 @@ define(function(require) { formatter: _.extend({}, Backgrid.CellFormatter.prototype, { fromRaw: function (rawValue,model) { return _.isUndefined(rawValue) ? '--': - '<span title="'+XAUtils.escapeHtmlChar(rawValue) +'" class="showMore">'+XAUtils.escapeHtmlChar(rawValue)+'</span>'; + '<span title="'+_.escape(rawValue) +'" class="showMore">'+_.escape(rawValue)+'</span>'; } }) }, @@ -1047,6 +1049,7 @@ define(function(require) { sortable:false, formatter: _.extend({}, Backgrid.CellFormatter.prototype, { fromRaw: function (rawValue, model) { + rawValue = _.escape(rawValue); return '<span title="'+rawValue+'">'+rawValue+'</span>'; } }), http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/cc74ff2e/security-admin/src/main/webapp/scripts/views/users/UserForm.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/views/users/UserForm.js b/security-admin/src/main/webapp/scripts/views/users/UserForm.js index a447baf..b4e5138 100644 --- a/security-admin/src/main/webapp/scripts/views/users/UserForm.js +++ b/security-admin/src/main/webapp/scripts/views/users/UserForm.js @@ -52,7 +52,7 @@ define(function(require){ /** all events binding here */ bindEvents : function(){ this.on('userRoleList:change', function(form, fieldEditor){ -// this.userRoleListChange(form, fieldEditor); + //this.userRoleListChange(form, fieldEditor); }); }, /** fields for the form @@ -83,12 +83,12 @@ define(function(require){ firstName : { type : 'Text', title : localization.tt("lbl.firstName")+' *', - validators : ['required',{type:'regexp',regexp:/^[a-zA-Z][a-z0-9- ]*[a-zA-Z0-9]+$/,message :'First name to start with alphabets & can have hyphen,space.'}] + validators : ['required',{type:'regexp',regexp:/^[a-zA-Z][a-z0-9- ]*[a-zA-Z0-9]+$/,message :'First name should start with alphabets & can have hyphen, space.'}] }, lastName : { type : 'Text', title : localization.tt("lbl.lastName"), - validators : [{type:'regexp',regexp:/^[a-zA-Z][a-z0-9- ]*[a-zA-Z0-9]+$/,message :'Last name to start with alphabets & can have hyphen,space.'}] + validators : [{type:'regexp',regexp:/^[a-zA-Z][a-z0-9- ]*[a-zA-Z0-9]+$/,message :'Last name should start with alphabets & can have hyphen, space.'}] }, emailAddress : { type : 'Text', @@ -198,14 +198,16 @@ define(function(require){ beforeSaveUserDetail : function(){ if(this.model.get('userSource') != XAEnums.UserSource.XA_USER.value){ var groupArr = this.$('[data-customfields="groupIdList"]').find('.tags').editable('getValue', true); - if(_.isNumber(groupArr)) + if(_.isNumber(groupArr)){ groupArr = groupArr.toString().split(','); + } this.model.set('groupIdList',groupArr); this.model.set('status',XAEnums.ActivationStatus.ACT_STATUS_ACTIVE.value); this.model.unset('passwordConfirm'); } - if(!this.model.isNew()) + if(!this.model.isNew()){ this.model.unset('password'); + } //FOR USER ROLE if(this.fields.userRoleList.getValue() == XAEnums.UserRoles.ROLE_USER.value){ this.model.set('userRoleList',["ROLE_USER"]); @@ -226,4 +228,4 @@ define(function(require){ }); return UserForm; -}); \ No newline at end of file +}); http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/cc74ff2e/security-admin/src/main/webapp/templates/helpers/XAHelpers.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/templates/helpers/XAHelpers.js b/security-admin/src/main/webapp/templates/helpers/XAHelpers.js index d2926af..537baa3 100644 --- a/security-admin/src/main/webapp/templates/helpers/XAHelpers.js +++ b/security-admin/src/main/webapp/templates/helpers/XAHelpers.js @@ -525,7 +525,7 @@ </div>' } tr += '<tr><td><div>\ - <a data-id="'+serv.id+'" href="#!/service/'+serv.id+'/policies">'+serv.attributes.name+'</a>'+serviceOperationDiv+'\ + <a data-id="'+serv.id+'" href="#!/service/'+serv.id+'/policies">'+_.escape(serv.attributes.name)+'</a>'+serviceOperationDiv+'\ </div></td></tr>'; }); }
