From ba62152bfdad584c231dc3e941cd1974dd5d881c Mon Sep 17 00:00:00 2001 From: Antonio Gallo Date: Tue, 18 Oct 2011 17:38:01 +0000 Subject: more characters are now allowed for the kernel entry --- .../Controllers/NotebooksController.php | 6 +++--- .../Application/Controllers/PrintersController.php | 22 +++++++++++----------- h-source/Application/Include/hardware.php | 9 ++++++++- h-source/Application/Models/HardwareModel.php | 20 ++++++++++---------- 4 files changed, 32 insertions(+), 25 deletions(-) diff --git a/h-source/Application/Controllers/NotebooksController.php b/h-source/Application/Controllers/NotebooksController.php index febf5f9..45f8b17 100644 --- a/h-source/Application/Controllers/NotebooksController.php +++ b/h-source/Application/Controllers/NotebooksController.php @@ -44,8 +44,8 @@ class NotebooksController extends GenericController //hardware conditions $this->m['HardwareModel']->strongConditions['update'] = array( "checkIsStrings|".Notebooks::vendorsList() => "vendor", - "checkNotEmpty" => "model|you have to fill the model name entry", - "checkMatch|/^[a-zA-Z0-9\-\_\.\+\s\(\)\[\]\/]+$/" => "model|characters not allowed in the model name entry", + "checkNotEmpty" => "model|you have to fill the model name entry", + "checkMatch|".Hardware::$regExpressions['model'] => "model|characters not allowed in the model name entry", "+checkIsStrings|".Notebooks::compatibilityList() => "compatibility", "checkLength|99" => "model", "+checkLength|299" => "distribution", @@ -62,7 +62,7 @@ class NotebooksController extends GenericController $this->m['HardwareModel']->strongConditions['insert'] = $this->m['HardwareModel']->strongConditions['update']; $this->m['HardwareModel']->softConditions['update'] = array( - "checkMatch|/^[a-zA-Z0-9\-\_\.\+\s]+$/" => "kernel|characters not allowed in the kernel entry", + "checkMatch|".Hardware::$regExpressions['kernel'] => "kernel|characters not allowed in the kernel entry", "checkLength|20000" => "description", "++checkLength|99" => "video_card_type,wifi_type", "+++checkLength|49" => "kernel", diff --git a/h-source/Application/Controllers/PrintersController.php b/h-source/Application/Controllers/PrintersController.php index d8cfe38..3e59702 100644 --- a/h-source/Application/Controllers/PrintersController.php +++ b/h-source/Application/Controllers/PrintersController.php @@ -43,11 +43,11 @@ class PrintersController extends GenericController //hardware conditions $this->m['HardwareModel']->strongConditions['update'] = array( - "checkNotEmpty" => "model|you have to fill the model name entry", - "checkMatch|/^[a-zA-Z0-9\-\_\.\+\s\(\)\[\]\/]+$/" => "model|characters not allowed in the model name entry", - "+checkMatch|/^[a-zA-Z0-9]{4}(\:)[a-zA-Z0-9]{4}$/" => "pci_id|VendorID:ProductID has to have the following format: [a-zA-Z0-9]{4}(\:)[a-zA-Z0-9]{4}", - "checkLength|99" => "model", - "+checkLength|299" => "distribution", + "checkNotEmpty" => "model|you have to fill the model name entry", + "checkMatch|".Hardware::$regExpressions['model'] => "model|characters not allowed in the model name entry", + "+checkMatch|".Hardware::$regExpressions['vendorid_productid'] => "pci_id|VendorID:ProductID has to have the following format: [a-zA-Z0-9]{4}(\:)[a-zA-Z0-9]{4}", + "checkLength|99" => "model", + "+checkLength|299" => "distribution", "+checkIsStrings|".Printer::compatibilityList() => "compatibility", "++checkIsStrings|".Printer::$commYear => "comm_year", "+++checkIsStrings|".Printer::$interface => "interface", @@ -58,12 +58,12 @@ class PrintersController extends GenericController $this->m['HardwareModel']->strongConditions['insert'] = $this->m['HardwareModel']->strongConditions['update']; $this->m['HardwareModel']->softConditions['update'] = array( - "checkMatch|/^[a-zA-Z0-9\-\_\.\+\s]+$/" => "kernel|characters not allowed in the kernel entry", - "checkLength|20000" => "description", - "+checkLength|49" => "driver", - "++checkLength|49" => "kernel", - "++checkMatch|/^[a-zA-Z0-9\-\_\.\+\s\/\,\:\;\(\)\[\]]+$/" => "driver|only the following characters are allowed for the driver entry: a-z A-Z 0-9 - _ . + s / , : ; ( ) [ ]", - "+++checkLength|1000" => "other_names|the other names entry exceeds the value of 1000 characters", + "checkMatch|".Hardware::$regExpressions['kernel'] => "kernel|characters not allowed in the kernel entry", + "checkLength|20000" => "description", + "+checkLength|49" => "driver", + "++checkLength|49" => "kernel", + "++checkMatch|".Hardware::$regExpressions['driver'] => "driver|only the following characters are allowed for the driver entry: a-z A-Z 0-9 - _ . + s / , : ; ( ) [ ]", + "+++checkLength|1000" => "other_names|the other names entry exceeds the value of 1000 characters", ); $this->m['HardwareModel']->softConditions['insert'] = $this->m['HardwareModel']->softConditions['update']; diff --git a/h-source/Application/Include/hardware.php b/h-source/Application/Include/hardware.php index 8248316..8caff1a 100644 --- a/h-source/Application/Include/hardware.php +++ b/h-source/Application/Include/hardware.php @@ -30,7 +30,14 @@ class Hardware { public static $translations = array( - "amd64" => 'x86-64/amd64', + "amd64" => 'x86-64/amd64', + ); + + public static $regExpressions = array( + "kernel" => "/^[a-zA-Z0-9\-\_\.\+\s\(\)\,]+$/", + "driver" => "/^[a-zA-Z0-9\-\_\.\+\s\/\,\:\;\(\)\[\]]+$/", + "vendorid_productid" => "/^[a-zA-Z0-9]{4}(\:)[a-zA-Z0-9]{4}$/", + "model" => "/^[a-zA-Z0-9\-\_\.\+\s\(\)\@\[\]\/]+$/", ); public static function translate($string) diff --git a/h-source/Application/Models/HardwareModel.php b/h-source/Application/Models/HardwareModel.php index 9a40e4b..7978593 100644 --- a/h-source/Application/Models/HardwareModel.php +++ b/h-source/Application/Models/HardwareModel.php @@ -77,10 +77,10 @@ class HardwareModel extends Model_Map { { $this->strongConditions['update'] = array( "checkNotEmpty" => "model|you have to fill the model name entry", - "checkMatch|/^[a-zA-Z0-9\-\_\.\+\s\(\)\@\[\]\/]+$/" => "model|characters not allowed in the model name entry", - "+checkMatch|/^[a-zA-Z0-9]{4}(\:)[a-zA-Z0-9]{4}$/" => "pci_id|VendorID:ProductID has to have the following format: [a-zA-Z0-9]{4}(\:)[a-zA-Z0-9]{4}", - "checkLength|99" => "model", - "+checkLength|299" => "distribution", + "checkMatch|".Hardware::$regExpressions['model'] => "model|characters not allowed in the model name entry", + "+checkMatch|".Hardware::$regExpressions['vendorid_productid'] => "pci_id|VendorID:ProductID has to have the following format: [a-zA-Z0-9]{4}(\:)[a-zA-Z0-9]{4}", + "checkLength|99" => "model", + "+checkLength|299" => "distribution", "++checkIsStrings|".Wifi::$commYear => "comm_year", "+++checkIsStrings|".$worksOptions => $worksField, "++++checkIsStrings|".$interfaceOptions => "interface", @@ -89,12 +89,12 @@ class HardwareModel extends Model_Map { $this->strongConditions['insert'] = $this->strongConditions['update']; $this->softConditions['update'] = array( - "checkMatch|/^[a-zA-Z0-9\-\_\.\+\s]+$/" => "kernel|characters not allowed in the kernel entry", - "checkLength|20000" => "description", - "+checkLength|49" => "kernel", - "++checkLength|49" => "driver", - "++checkMatch|/^[a-zA-Z0-9\-\_\.\+\s\/\,\:\;\(\)\[\]]+$/" => "driver|only the following characters are allowed for the driver entry: a-z A-Z 0-9 - _ . + s / , : ; ( ) [ ]", - "+++checkLength|1000" => "other_names|the other names entry exceeds the value of 1000 characters", + "checkMatch|".Hardware::$regExpressions['kernel'] => "kernel|characters not allowed in the kernel entry", + "checkLength|20000" => "description", + "+checkLength|49" => "kernel", + "++checkLength|49" => "driver", + "++checkMatch|".Hardware::$regExpressions['driver'] => "driver|only the following characters are allowed for the driver entry: a-z A-Z 0-9 - _ . + s / , : ; ( ) [ ]", + "+++checkLength|1000" => "other_names|the other names entry exceeds the value of 1000 characters", ); $this->softConditions['insert'] = $this->softConditions['update']; -- cgit v1.2.3