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

xemlock / htmlpurifier-html5 / 13168072550

05 Feb 2025 10:52PM UTC coverage: 99.406%. Remained the same
13168072550

push

github

xemlock
Adjust tests for HTMLPurifier 4.18.0

Support for conditional comments was removed in HTMLPurifier 4.18.0,
see: https://github.com/ezyang/htmlpurifier/commit/4828fdf.

1507 of 1516 relevant lines covered (99.41%)

3215.37 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');
970✔
27
        return true;
970✔
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')) {
960✔
40
            return true;
850✔
41
        }
42

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

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

53
        // actually check the whitelists
54
        return preg_match($this->regexp, $uri->toString());
100✔
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