Can I make the protocol scheme for URL parsing configurable? #1053
-
|
Moin people! The core function It would be great if this list could be customised via system settings. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
I tried to modify the yellow-core accordingly. One of you may take a look at upputter/yellow@49bfb35 With this little tweak, you can add further protocols to the url parsing of yellow, e.g.: |
Beta Was this translation helpful? Give feedback.
-
|
Another attempt would be to keep the yellow core untouched and use a little extension. I fiddeled around a bit and came to a rather nice solution, I think: <?php
// get the global yellow core
global $yellow;
// set default protocols
$yellow->system->setDefault("coreSafeUrlProtocols", "http,https,ftp,mailto,tel");
// override yellow lookup
$yellow->lookup = new YellowLookupExtended($yellow);
class YellowLookupExtended extends YellowLookup
{
public function isSafeUrl($url)
{
$protocols = implode('|', preg_split("/\s*,\s*/", $this->yellow->system->get("coreSafeUrlProtocols")));
return preg_match("/^(" . $protocols . "):/", $url);
}
}It's like a normal yellow extension, but without any standard methods. While being loaded in the process of the normal extension loading, it will:
The - now modified - yellow core uses the extended Works like charm! |
Beta Was this translation helpful? Give feedback.
Another attempt would be to keep the yellow core untouched and use a little extension.
I fiddeled around a bit and came to a rather nice solution, I think:
It's like a normal yellow ext…