Seldaek
IRC URIScheme class
November 27, 2007 03:01PM

Hello, here is a irc.php URIScheme file, I think the irc:// URIs potential to harm anyone is about 0% so I hope you'll include it in further releases, that way I don't have to hack it in.

Thanks for the fine job on this project by the way, it's much appreciated.

<?php

require_once &#039;HTMLPurifier/URIScheme.php&#039;;

/**
 * Validates irc (Internet Relay Chat) URIs as defined by generic mIRC, see http://www.mirc.com/mirclink.html
 */
class HTMLPurifier_URIScheme_irc extends HTMLPurifier_URIScheme {

    var $browsable = false;
    var $default_port = 6667;

    function validate(&$uri, $config, &$context) {
        parent::validate($uri, $config, $context);
        // strip unused parts
        $uri->userinfo = null;
        $uri->fragment = null;
		// channel (path) or server (host) can be empty, but not both
        if($uri->host == "" && ($uri->path == "/" || $uri->path == ""))
			return false;
        return true;
    }
}
?>

And should you not include it, if anyone is interested to add this to his parser, here is the code I use :

require_once &#039;path/to/library/HTMLPurifier/URIScheme/irc.php&#039;;
HTMLPurifier_URISchemeRegistry::instance()->register(&#039;irc&#039;, new HTMLPurifier_URIScheme_irc());

By the way, there is supposedly a way to do this with $config->set('URI', 'AllowedSchemes', array('http' => true, 'https' => true, 'mailto' => true, 'ftp' => true, 'nntp' => true, 'news' => true, 'irc' => true)); but I could not get it to work so that's why I did it as shown above..

Re: IRC URIScheme class
December 12, 2007 05:59PM

My apologies for waiting so long before following up on this. I'll probably add this with 3.0.0, pending the addition of some unit tests. Also, if AllowedSchemes was unclear about its function, I'll update those docs.

Sorry, you do not have permission to post/reply in this forum.