• 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/Float.php
1
<?php
2

3
/**
4
 * Validates a floating point number
5
 */
6
class HTMLPurifier_AttrDef_HTML5_Float extends HTMLPurifier_AttrDef
7
{
8
    /**
9
     * @var int|float
10
     */
11
    protected $min;
12

13
    /**
14
     * @var int|float
15
     */
16
    protected $max;
17

18
    /**
19
     * @var bool
20
     */
21
    protected $minInclusive = true;
22

23
    /**
24
     * @var bool
25
     */
26
    protected $maxInclusive = true;
27

28
    /**
29
     * Supported options:
30
     *
31
     * - 'min'          => int|float
32
     * - 'max'          => int|float
33
     * - 'minInclusive' => bool
34
     * - 'maxInclusive' => bool
35
     *
36
     * @param array $options OPTIONAL
37
     */
38
    public function __construct($options = null)
39
    {
40
        $options = is_array($options) ? $options : array();
10,368✔
41

42
        $this->min = isset($options['min']) ? floatval($options['min']) : null;
10,368✔
43
        $this->max = isset($options['max']) ? floatval($options['max']) : null;
10,368✔
44

45
        if (isset($options['minInclusive'])) {
10,368✔
46
            $this->minInclusive = (bool) $options['minInclusive'];
10,356✔
47
        }
1,726✔
48

49
        if (isset($options['maxInclusive'])) {
10,368✔
50
            $this->maxInclusive = (bool) $options['maxInclusive'];
24✔
51
        }
4✔
52
    }
4,320✔
53

54
    /**
55
     * @param string $number
56
     * @param HTMLPurifier_Config $config
57
     * @param HTMLPurifier_Context $context
58
     * @return bool|string
59
     */
60
    public function validate($number, $config, $context)
61
    {
62
        $number = $this->parseCDATA($number);
228✔
63

64
        if ($number === '') {
228✔
65
            return false;
12✔
66
        }
67

68
        // Up to PHP 5.6 is_numeric() returns TRUE for hex strings
69
        // http://php.net/manual/en/function.is-numeric.php
70
        if (!preg_match('/^[-+.0-9Ee]+$/', $number) || !is_numeric($number)) {
228✔
71
            return false;
24✔
72
        }
73

74
        // HTML numbers cannot start with '+' character
75
        // https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-floating-point-number
76
        if (substr($number, 0, 1) === '+') {
216✔
77
            $number = substr($number, 1);
12✔
78
        }
2✔
79

80
        $value = floatval($number);
216✔
81

82
        if (($this->min !== null) &&
216✔
83
            (($this->minInclusive && $value < $this->min) || (!$this->minInclusive && $value <= $this->min))
214✔
84
        ) {
36✔
85
            return false;
24✔
86
        }
87

88
        if (($this->max !== null) &&
204✔
89
            (($this->maxInclusive && $this->max < $value) || (!$this->maxInclusive && $this->max <= $value))
172✔
90
        ) {
34✔
91
            return false;
12✔
92
        }
93

94
        return $number;
204✔
95
    }
96

97
    /**
98
     * Factory function
99
     *
100
     * @param string $string A comma-delimited list of key:value pairs. Example: "min:0,max:10".
101
     * @return HTMLPurifier_AttrDef_HTML5_Float
102
     */
103
    public function make($string)
104
    {
105
        $options = array();
12✔
106
        foreach (explode(',', $string) as $pair) {
12✔
107
            $parts = explode(':', $pair, 2);
12✔
108
            if (count($parts) === 2) {
12✔
109
                list($key, $value) = $parts;
12✔
110
                $options[$key] = $value;
12✔
111
            }
2✔
112
        }
2✔
113
        $class = get_class($this);
12✔
114
        return new $class($options);
12✔
115
    }
116
}
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