Hodges |
|
---|---|
Hi, Can anyone help me add the tel: URI scheme to HTMLPurifier? All the example instructions on doing this refer to path structures dissimilar from Cotonti's implementation of HTMLPurifier. Cheers, |
Macik |
|
---|---|
If it still actual, here are the example code — add it to `htmlpurifier.group_5.preset.php` (admin group preset): class HTMLPurifier_URIScheme_tel extends HTMLPurifier_URIScheme { public $browsable = false; public $may_omit_host = true; public function doValidate(&$uri, $config, $context) { $uri->userinfo = null; $uri->host = null; $uri->port = null; $validCalltoPhoneNumberPattern = '/^\+?[\(\)\.0-9_-]+$/i'; // <---whatever pattern you want to force phone numbers to match $proposedPhoneNumber = $uri->path; // defined phone if (preg_match($validCalltoPhoneNumberPattern, $proposedPhoneNumber) !== 1) { return FALSE; } else { return TRUE; } } } $config->set('URI.AllowedSchemes', array ('http' => true, 'https' => true, 'mailto' => true, 'ftp' => true, 'nntp' => true, 'news' => true, 'tel' => true,)); HTMLPurifier_URISchemeRegistry::instance()->register(new HTMLPurifier_URIScheme_tel, $config);
Update: starting from version 4.8.0 HTML Purifier support `tel:` scheme by default. https://github.com/macik
правильный хостинг — https://goo.gl/fjCa1F |
|
This post was edited by Macik (2017-11-23 00:56, 7 years ago) |