HTML Purifier 4.2.0 的 IRC URI 方案请求

发布于 2024-10-16 00:24:49 字数 694 浏览 6 评论 0原文

有人可以帮助我为 HTML Purifier 4.2.0 建立使用 IRC URI 方案吗?我似乎不知道如何配置或修改哪些文件,以便纯化的 html 允许 irc:// 链接。

我是否可以简单地修改以下代码块中的配置?

require_once "htmlpurifier-4.2.0/library/HTMLPurifier.standalone.php";
$purifier_config = HTMLPurifier_Config::createDefault();
$purifier_config->set("HTML.Doctype", "XHTML 1.0 Strict");
$purifier = new HTMLPurifier($purifier_config);

更新:

我编辑了library/standalone/HTMLPurifier/ConfigSchema/schema.ser,将“4:nntp”的两个实例更改为“3:irc”并发现错误:

警告:目录htmlpurifier-4.2.0/library/standalone/HTMLPurifier/DefinitionCache /Serializer/URI 不可写,请 chmod 到 777

我相信这将有助于在进行此更改后建立对 IRC URI 方案的支持。我稍后会报告。

嗯,设为可写后,没有出现错误,但是没有结果=\

Can someone help me to establish using IRC URI Scheme for HTML Purifier 4.2.0? I can't seem to figure out how to configure or which files to modify so that purified html allows for irc:// links.

Is it possible I can simply modify configuration within the following code block?

require_once "htmlpurifier-4.2.0/library/HTMLPurifier.standalone.php";
$purifier_config = HTMLPurifier_Config::createDefault();
$purifier_config->set("HTML.Doctype", "XHTML 1.0 Strict");
$purifier = new HTMLPurifier($purifier_config);

Update:

I edited library/standalone/HTMLPurifier/ConfigSchema/schema.ser changing both instances of "4:nntp" to "3:irc" and found error:

Warning: Directory htmlpurifier-4.2.0/library/standalone/HTMLPurifier/DefinitionCache/Serializer/URI not writable, please chmod to 777

I believe this will help to establish support for IRC URI Scheme after making this change. I'll report back in a bit.

Hmm, after making it writable, no error appeared, but no results =\

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦在深巷 2024-10-23 00:24:49

HTML Purifier 似乎没有对 IRC 方案的本机支持。但是:你尝试过这样的事情吗?将其放入 /library/HTMLPurifier/URIScheme 中,或者确保自动加载找到它:

class HTMLPurifier_URIScheme_irc extends HTMLPurifier_URIScheme {

    public $default_port = 6667;
    public $browsable = false;

    public function validate(&$uri, $config, $context) {
        if (parent::validate($uri, $config, $context) === false) {
            return false;
        }
        if (!is_null($uri->path)) {
            // get channel name
            $uri->path = array_shift(explode('/', $uri->path));
        }
        $uri->userinfo = null;
        $uri->query    = null;
        $uri->fragment = null;
        return true;
    }

}

...并使用...更改您的配置...

$purifier->config->set(
    'URI.AllowedSchemes',
    array('irc' => true, /* ... other schemes here ... */)
);

这可能无法开箱即用,但我认为这应该是正确的方向......

HTML Purifier doesn't seem to have a native support for the IRC scheme. But: Have you tried something like this? Put this in /library/HTMLPurifier/URIScheme, or otherwise make sure that autoloading finds it:

class HTMLPurifier_URIScheme_irc extends HTMLPurifier_URIScheme {

    public $default_port = 6667;
    public $browsable = false;

    public function validate(&$uri, $config, $context) {
        if (parent::validate($uri, $config, $context) === false) {
            return false;
        }
        if (!is_null($uri->path)) {
            // get channel name
            $uri->path = array_shift(explode('/', $uri->path));
        }
        $uri->userinfo = null;
        $uri->query    = null;
        $uri->fragment = null;
        return true;
    }

}

...and change your configuration with...

$purifier->config->set(
    'URI.AllowedSchemes',
    array('irc' => true, /* ... other schemes here ... */)
);

That may not work out of the box, but I'm thinking that should be the right direction...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文