cloudStack 3.0 UI - validation - add new method "disallowSpecialCharacters" which will disallow < and > (to prevent XSS attack) - apply this method in Add Domain dialog.

This commit is contained in:
Jessica Wang 2012-03-15 14:45:11 -07:00
parent 125a156485
commit 9d1d77ea77
2 changed files with 10 additions and 2 deletions

View File

@ -172,11 +172,11 @@
fields: {
name: {
label: 'label.name',
validation: { required: true }
validation: { required: true, disallowSpecialCharacters: true }
},
networkdomain: {
label: 'label.network.domain',
validation: { required: false }
validation: { required: false, disallowSpecialCharacters: true }
}
}
}

View File

@ -273,6 +273,14 @@
// Validation
$.extend($.validator.messages, { required: _l('label.required') });
$.validator.addMethod(
"disallowSpecialCharacters",
function(value, element) {
return (value.indexOf("<") == -1 && value.indexOf(">") == -1);
},
jQuery.format("Disallowed characters: <, >")
);
// Check for pending project invitations
cloudStack.projects.invitationCheck({