From 32dc829a4184fdeee8a96b1fbe4127b360343063 Mon Sep 17 00:00:00 2001 From: Loic d'Anterroches Date: Thu, 26 Feb 2009 11:09:38 +0100 Subject: [PATCH] Fixed issue 142, control the patch when creating a new code review. --- src/IDF/Form/ReviewCreate.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/IDF/Form/ReviewCreate.php b/src/IDF/Form/ReviewCreate.php index 19e7c8a..d10976f 100644 --- a/src/IDF/Form/ReviewCreate.php +++ b/src/IDF/Form/ReviewCreate.php @@ -108,6 +108,17 @@ class IDF_Form_ReviewCreate extends Pluf_Form } } + public function clean_patch() + { + $diff = new IDF_Diff(file_get_contents(Pluf::f('upload_issue_path').'/' + .$this->cleaned_data['patch'])); + $diff->parse(); + if (count($diff->files) == 0) { + throw new Pluf_Form_Invalid(__('We were not able to parse your patch. Please provide a valid patch.')); + } + return $this->cleaned_data['patch']; + } + public function clean_commit() { $commit = self::findCommit($this->cleaned_data['commit']);