• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

xemlock / htmlpurifier-html5 / 13179873326

06 Feb 2025 01:28PM UTC coverage: 99.276% (-0.1%) from 99.406%
13179873326

push

github

web-flow
PHP 8.4 support (#84)

1 of 4 new or added lines in 1 file covered. (25.0%)

1508 of 1519 relevant lines covered (99.28%)

3883.48 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.0
/library/HTMLPurifier/URIFilter/HTML5/SafeLink.php
1
<?php
2

3
class HTMLPurifier_URIFilter_HTML5_SafeLink extends HTMLPurifier_URIFilter
4
{
5
    /**
6
     * @type string
7
     */
8
    public $name = 'HTML5_SafeLink';
9

10
    /**
11
     * @type bool
12
     */
13
    public $always_load = true;
14

15
    /**
16
     * @type string
17
     */
18
    protected $regexp = null;
19

20
    /**
21
     * @param HTMLPurifier_Config $config
22
     * @return bool
23
     */
24
    public function prepare($config)
25
    {
26
        $this->regexp = $config->get('URI.SafeLinkRegexp');
1,164✔
27
        return true;
1,164✔
28
    }
29

30
    /**
31
     * @param HTMLPurifier_URI $uri
32
     * @param HTMLPurifier_Config $config
33
     * @param HTMLPurifier_Context $context
34
     * @return bool
35
     */
36
    public function filter(&$uri, $config, $context)
37
    {
38
        // check if filter not applicable
39
        if (!$config->get('HTML.SafeLink')) {
1,152✔
40
            return true;
1,020✔
41
        }
42

43
        $token = $context->get('CurrentToken', true);
132✔
44
        if (!($token && $token->name == 'link')) {
132✔
45
            return true;
×
46
        }
47

48
        // check if we actually have some whitelists enabled
49
        if ($this->regexp === null) {
132✔
50
            return false;
12✔
51
        }
52

53
        // actually check the whitelists
54
        return preg_match($this->regexp, $uri->toString());
120✔
55
    }
56
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc