HTMLPurifier 在 href 链接上盯着数字的问题


Issue with HTMLPurifier on href links staring with number

我在PHP HTMLPurifier库时遇到了一个问题。我面临的问题是以下输入字符串

Update

对于上述输入,我得到纯化的输出为

Update

我浏览了他们的文档。但是我无法找到该问题的解决方案。

源代码:

require_once("/html_purifier/library/HTMLPurifier.auto.php");
$config = HTMLPurifier_Config::createDefault();
$text= "<a href='"http://1plusone/com/Update'">Update</a>";
$oPurifier = new HTMLPurifier($config);
$purifiedHtml= $oPurifier->purify($text);
echo $purifiedHtml;

我也尝试过这个htmlpurifier的现场演示。它也给出了相同的结果。

请帮忙。

HTML 净化器似乎拒绝只有一个部分具有前导数字的主机名。 相关代码HTMLPurifier/AttrDef/URI/Host.php

    // The productions describing this are:
    $a   = '[a-z]';     // alpha
    $an  = '[a-z0-9]';  // alphanum
    $and = "[a-z0-9-$underscore]"; // alphanum | "-"
    // domainlabel = alphanum | alphanum *( alphanum | "-" ) alphanum
    $domainlabel = "$an($and*$an)?";
    // toplabel    = alpha | alpha *( alphanum | "-" ) alphanum
    $toplabel = "$a($and*$an)?";
    // hostname    = *( domainlabel "." ) toplabel [ "." ]
    if (preg_match("/^($domainlabel'.)*$toplabel'.?$/i", $string)) {
        return $string;
    }

一个简单的修复可能会修补它以使其更宽松。我不知道是否有更新的 RFC 允许您所描述的内容。