Fixing issue 85

Fixing old issue 68
Fixing old issue 45
This commit is contained in:
Nathan Adams 2014-12-27 19:33:57 -06:00
parent d0095cb454
commit cc6f2b2ca8
3 changed files with 16 additions and 1 deletions

View File

@ -50,6 +50,17 @@ class IDF_Form_ProjectRequest extends Pluf_Form
throw new Exception(__('Cannot save the model from an invalid form.'));
}
$shortname = $this->cleaned_data['shortname'];
if (preg_match('/[^\-A-Za-z0-9]/', $shortname)) {
throw new Pluf_Form_Invalid(__('This shortname contains illegal characters, please use only letters, digits and dash (-).'));
}
if (mb_substr($shortname, 0, 1) == '-') {
throw new Pluf_Form_Invalid(__('The shortname cannot start with the dash (-) character.'));
}
if (mb_substr($shortname, -1) == '-') {
throw new Pluf_Form_Invalid(__('The shortname cannot end with the dash (-) character.'));
}
$checksql = new Pluf_SQL(sprintf("shortname='%s'", $this->cleaned_data['shortname']));
$requestcheck = Pluf::factory("IDF_Project")->getCount(array('filter'=>$checksql->gen()));
if ($requestcheck == 1)
@ -57,7 +68,9 @@ class IDF_Form_ProjectRequest extends Pluf_Form
try
{
$request = new IDF_ProjectRequest();
$request->shortname = $this->cleaned_data['shortname'];
// The trim really isn't needed - but does ensure that no whitespace will end up in the name
$request->shortname = trim($shortname);
$request->repotype = $this->cleaned_data['repotype'];
$request->desc = $this->cleaned_data['desc'];
$request->submitter = $this->user;

View File

@ -131,6 +131,7 @@ class IDF_Views_Source
'tags' => $tags,
'tags_in' => $in_tags,
'scm' => $scmConf,
'numcommits' => count($rchanges),
'full' => isset($_GET["full"]) ? true : false
),
$request);

View File

@ -35,5 +35,6 @@
{/foreach}
</ul>
{/if}
Number of commits: {$numcommits}
</div>