From 3f6afa2904a07774794ee8bc4a94e4b989613008 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Tue, 19 Feb 2008 22:46:30 +0000 Subject: [PATCH] Merged revisions 49834 via svnmerge from svn://svn.silverstripe.com/silverstripe/modules/sapphire/branches/2.2.0-mesq ........ r49834 | ischommer | 2008-02-20 11:45:56 +1300 (Wed, 20 Feb 2008) | 1 line fixed sql-injection ........ git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@49828 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- forms/AjaxUniqueTextField.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/forms/AjaxUniqueTextField.php b/forms/AjaxUniqueTextField.php index 5447ddcde..ff84a97dd 100644 --- a/forms/AjaxUniqueTextField.php +++ b/forms/AjaxUniqueTextField.php @@ -107,7 +107,12 @@ JS; function validate( $validate ) { - $result = DB::query( "SELECT COUNT(*) FROM " . $this->restrictedTable . " WHERE " . $this->restrictedField . " = '" . $this->value . "'" )->value(); + $result = DB::query(sprintf( + "SELECT COUNT(*) FROM `%s` WHERE `%s` = '%s'", + $this->restrictedTable, + $this->restrictedField, + Convert::raw2sql($this->value) + ))->value(); if( $result && ( $result > 0 ) ) { $validator->validationError( $this->name, _t('Form.VALIDATIONNOTUNIQUE', "The value entered is not unique") );