Skip to content
Browse files

MDL-40700 cache: Validate memcache key prefix field

  • Loading branch information...
1 parent 7aed82f commit fe6eeced0b2775863fb197d2d5d112580bed4757 @PeloNZ PeloNZ committed with Sam Hemelryk Jul 18, 2013
Showing with 3 additions and 1 deletion.
  1. +2 −1 cache/stores/memcache/addinstanceform.php
  2. +1 −0 lang/en/cache.php
View
3 cache/stores/memcache/addinstanceform.php
@@ -49,7 +49,8 @@ protected function configuration_definition() {
$form->addElement('text', 'prefix', get_string('prefix', 'cachestore_memcache'),
array('maxlength' => 5, 'size' => 5));
$form->addHelpButton('prefix', 'prefix', 'cachestore_memcache');
- $form->setType('prefix', PARAM_ALPHAEXT);
+ $form->addRule('prefix', get_string('storeprefixinvalid', 'cache'), 'regex', '#^[a-zA-Z0-9\-_ ]+$#');
+ $form->setType('prefix', PARAM_TEXT);
$form->setDefault('prefix', 'mdl_');
}
}
View
1 lang/en/cache.php
@@ -143,6 +143,7 @@
$string['storenamealreadyused'] = 'You must choose a unique name for this store.';
$string['storenameinvalid'] = 'Invalid store name. You can only use a-z A-Z 0-9 -_ and spaces.';
$string['storeperformance'] = 'Cache store performance reporting - {$a} unique requests per operation.';
+$string['storeprefixinvalid'] = 'Invalid store prefix. You can only use a-z A-Z 0-9 -_ and spaces.';
$string['storeready'] = 'Ready';
$string['storenotready'] = 'Store not ready';
$string['storerequiresattention'] = 'Requires attention.';

0 comments on commit fe6eece

Please sign in to comment.
Something went wrong with that request. Please try again.