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

xemlock / htmlpurifier-html5 / 16898969866

12 Aug 2025 04:28AM UTC coverage: 99.276%. Remained the same
16898969866

Pull #87

github

web-flow
Bump actions/checkout from 4 to 5

Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 5.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #87: Bump actions/checkout from 4 to 5

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

100.0
/library/HTMLPurifier/AttrDef/HTML5/InputType.php
1
<?php
2

3
class HTMLPurifier_AttrDef_HTML5_InputType extends HTMLPurifier_AttrDef
4
{
5
    /**
6
     * Lookup table for valid values
7
     * @var array
8
     * @see https://www.w3.org/TR/xhtml-modularization/abstract_modules.html#s_extformsmodule
9
     */
10
    protected static $values = array(
11
        'button' => true,
12
        'checkbox' => true,
13
        'file' => true,
14
        'hidden' => true,
15
        'image' => true,
16
        'password' => true,
17
        'radio' => true,
18
        'reset' => true,
19
        'submit' => true,
20
        'text' => true,
21
    );
22

23
    /**
24
     * Lookup for input types allowed in current configuration
25
     * @var array
26
     */
27
    protected $allowed;
28

29
    protected $allowedFromConfig;
30

31
    protected function setupAllowed(HTMLPurifier_Config $config)
32
    {
33
        $allowedFromConfig = isset($config->def->info['Attr.AllowedInputTypes'])
648✔
34
            ? $config->get('Attr.AllowedInputTypes')
648✔
35
            : null;
378✔
36

37
        // Check if current allowed value is based on the latest value from config.
38
        // Comparing with '===' shouldn't be a performance bottleneck, because the
39
        // value retrieved from the config is never changed after being stored.
40
        // PHP's copy-on-write mechanism prevents making unnecessary array copies,
41
        // allowing this particular array comparison to be made in O(1) time, when
42
        // the corresponding value in config hasn't changed, and in O(n) time after
43
        // each change.
44
        if ($this->allowed !== null && $this->allowedFromConfig === $allowedFromConfig) {
648✔
45
            return;
96✔
46
        }
47

48
        if (is_array($allowedFromConfig)) {
648✔
49
            $allowed = array_intersect_key($allowedFromConfig, self::$values);
48✔
50
        } else {
8✔
51
            $allowed = self::$values;
612✔
52
        }
53

54
        $this->allowed = $allowed;
648✔
55
        $this->allowedFromConfig = $allowedFromConfig;
648✔
56
    }
270✔
57

58
    /**
59
     * @param string $string
60
     * @param HTMLPurifier_Config $config
61
     * @param HTMLPurifier_Context $context
62
     * @return bool|string
63
     */
64
    public function validate($string, $config, $context)
65
    {
66
        $this->setupAllowed($config);
648✔
67
        $value = strtolower($this->parseCDATA($string));
648✔
68

69
        if (!isset(self::$values[$value])) {
648✔
70
            return false;
60✔
71
        }
72

73
        if (!isset($this->allowed[$value])) {
612✔
74
            return false;
48✔
75
        }
76

77
        return $value;
588✔
78
    }
79
}
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