1<?php 2 3namespace dokuwiki\plugin\config\core\Setting; 4 5/** 6 * Class setting_regex 7 */ 8class SettingRegex extends SettingString 9{ 10 11 protected $delimiter = '/'; // regex delimiter to be used in testing input 12 protected $pregflags = 'ui'; // regex pattern modifiers to be used in testing input 13 14 /** @inheritdoc */ 15 public function update($input) 16 { 17 18 // let parent do basic checks, value, not changed, etc. 19 $local = $this->local; 20 if(!parent::update($input)) return false; 21 $this->local = $local; 22 23 // see if the regex compiles and runs (we don't check for effectiveness) 24 $regex = $this->delimiter . $input . $this->delimiter . $this->pregflags; 25 $lastError = error_get_last(); 26 @preg_match($regex, 'testdata'); 27 if(preg_last_error() != PREG_NO_ERROR || error_get_last() !== $lastError) { 28 $this->input = $input; 29 $this->error = true; 30 return false; 31 } 32 33 $this->local = $input; 34 return true; 35 } 36} 37