NorbertH Posted February 6, 2019 Share Posted February 6, 2019 I really would like to see a sanitzer that uses a regex!! $sanitize->regex($value, $regex); Simply return empty if the value doesn't match. It would be even better if we got an extra option for replacements and or callback functions. If i have seen it right, there are even sanitizer that use HTMLpurifier so why is there no regex implemented as its one of PHP's most powerfull features ? Sanitizer since PW 2.6.14 integrates nicely whith $input and so on , so using a seperate preg_match()/preg_replace() isn't as elegant as using sanitizer. Link to comment Share on other sites More sharing options...
Zeka Posted February 6, 2019 Share Posted February 6, 2019 https://processwire.com/api/ref/sanitizer/match/ 2 1 Link to comment Share on other sites More sharing options...
NorbertH Posted February 6, 2019 Author Share Posted February 6, 2019 Still no replacement possible ? Thinking this through it would be even greater if you could add custom sanitizer as modules. Maybe like : $sanitize->call($value, 'moduleName', $arguments); Link to comment Share on other sites More sharing options...
Wanze Posted February 7, 2019 Share Posted February 7, 2019 It's possible! From the Sanitizer class description: Quote * Modules may also add methods to the Sanitizer as needed i.e. $this->sanitizer->addHook('myMethod', $myClass, 'myMethod'); * See the Wire class definition for more details about the addHook method. Cheers:) 4 Link to comment Share on other sites More sharing options...
bernhard Posted February 7, 2019 Share Posted February 7, 2019 54 minutes ago, Wanze said: It's possible! From the Sanitizer class description: Quote * Modules may also add methods to the Sanitizer as needed i.e. $this->sanitizer->addHook('myMethod', $myClass, 'myMethod'); * See the Wire class definition for more details about the addHook method. Cheers:) 13 hours ago, NorbertH said: Thinking this through it would be even greater if you could add custom sanitizer as modules. Would be nice to see a little tutorial when you manage to do it ? 2 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now