From cc6f2b2ca8b5cc0eeb509f403e5cd02781cdb775 Mon Sep 17 00:00:00 2001 From: Nathan Adams Date: Sat, 27 Dec 2014 19:33:57 -0600 Subject: [PATCH] Fixing issue 85 Fixing old issue 68 Fixing old issue 45 --- indefero/src/IDF/Form/ProjectRequest.php | 15 ++++++++++++++- indefero/src/IDF/Views/Source.php | 1 + .../templates/idf/source/git/branch_tag_list.html | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/indefero/src/IDF/Form/ProjectRequest.php b/indefero/src/IDF/Form/ProjectRequest.php index 782cd6c..a84a0d2 100644 --- a/indefero/src/IDF/Form/ProjectRequest.php +++ b/indefero/src/IDF/Form/ProjectRequest.php @@ -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; diff --git a/indefero/src/IDF/Views/Source.php b/indefero/src/IDF/Views/Source.php index cb3b525..bb64927 100644 --- a/indefero/src/IDF/Views/Source.php +++ b/indefero/src/IDF/Views/Source.php @@ -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); diff --git a/indefero/src/IDF/templates/idf/source/git/branch_tag_list.html b/indefero/src/IDF/templates/idf/source/git/branch_tag_list.html index b9c4026..e341604 100644 --- a/indefero/src/IDF/templates/idf/source/git/branch_tag_list.html +++ b/indefero/src/IDF/templates/idf/source/git/branch_tag_list.html @@ -35,5 +35,6 @@ {/foreach} {/if} + Number of commits: {$numcommits}