r81493 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81492‎ | r81493 | r81494 >
Date:23:20, 3 February 2011
Author:laner
Status:deferred
Tags:
Comment:
Add validation of project names to ensure they are also valid (and sane) posix group names.
Modified paths:
  • /trunk/extensions/OpenStackManager/OpenStackManager.i18n.php (modified) (history)
  • /trunk/extensions/OpenStackManager/special/SpecialNovaProject.php (modified) (history)

Diff [purge]

Index: trunk/extensions/OpenStackManager/special/SpecialNovaProject.php
@@ -54,6 +54,7 @@
5555 $projectInfo['projectname'] = array(
5656 'type' => 'text',
5757 'label-message' => 'openstackmanager-projectname',
 58+ 'validation-callback' => array( $this, 'validateProjectName' ),
5859 'default' => '',
5960 'section' => 'project/info',
6061 );
@@ -372,6 +373,20 @@
373374
374375 return true;
375376 }
 377+
 378+ /**
 379+ * @param $projectname
 380+ * @param $alldata
 381+ * @return bool|string
 382+ */
 383+ function validateProjectName( $projectname, $alldata ) {
 384+ if ( ! preg_match( "/^[a-z][a-z0-9\-_]*$/", $project ) ) {
 385+ return Xml::element( 'span', array( 'class' => 'error' ), wfMsg( 'openstackmanager-badprojectname' ) );
 386+ } else {
 387+ return true;
 388+ }
 389+ }
 390+
376391 }
377392
378393 class SpecialNovaProjectForm extends HTMLForm {
Index: trunk/extensions/OpenStackManager/OpenStackManager.i18n.php
@@ -126,6 +126,7 @@
127127 'openstackmanager-action' => 'Action',
128128 'openstackmanager-createprojectfailed' => 'Failed to create project.',
129129 'openstackmanager-createdproject' => 'Created project.',
 130+ 'openstackmanager-badprojectname' => 'Bad project name provided. Project names start with a-z, and can only contain a-z, 0-9, -, and _ characters.',
130131 'openstackmanager-projectlist' => 'Project list',
131132 'openstackmanager-backprojectlist' => 'Back to project list',
132133 'openstackmanager-deleteproject' => 'Delete project',

Status & tagging log