Permalink
Browse files

Validate DS and Event names. When components are handlised, non-latin…

…-based alphabets are truncated. Validation avoids the edge case where a file contains only non-ascii characters, which would create empty filenames.
  • Loading branch information...
1 parent 8ed9e89 commit 1ea7d2ca225955a6cccffb0e350b31f60108052b @allen allen committed Jun 28, 2011
@@ -934,8 +934,11 @@ public function __formAction(){
$classname = Lang::createHandle($fields['name'], NULL, '_', false, true, array('@^[^a-z]+@i' => '', '/[^\w-\.]/i' => ''));
$rootelement = str_replace('_', '-', $classname);
- $file = DATASOURCES . '/data.' . $classname . '.php';
+ ##Check to make sure the classname is not empty after handlisation.
+ if(empty($classname)) $this->_errors['name'] = __('Please ensure name contains at least one Latin-based alphabet.', array($classname));
+ $file = DATASOURCES . '/data.' . $classname . '.php';
+
$isDuplicate = false;
$queueForDeletion = NULL;
@@ -263,6 +263,9 @@ public function __formAction(){
$classname = Lang::createHandle($fields['name'], NULL, '_', false, true, array('@^[^a-z]+@i' => '', '/[^\w-\.]/i' => ''));
$rootelement = str_replace('_', '-', $classname);
+ ##Check to make sure the classname is not empty after handlisation.
+ if(empty($classname)) $this->_errors['name'] = __('Please ensure name contains at least one Latin-based alphabet.', array($classname));
+
$file = EVENTS . '/event.' . $classname . '.php';
$isDuplicate = false;

0 comments on commit 1ea7d2c

Please sign in to comment.