Issues (197)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

src/Element/Input.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace RoyallTheFourth\HtmlDocument\Element;
4
5
use RoyallTheFourth\HtmlDocument\Attribute\BooleanAttribute;
6
use RoyallTheFourth\HtmlDocument\Attribute\StandardAttribute;
7
use RoyallTheFourth\HtmlDocument\Set\AttributeSet;
8
use RoyallTheFourth\HtmlDocument\Tag\EmptyTag;
9
10
/**
11
 * Class Input
12
 * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input
13
 */
14
final class Input extends AbstractElement
15
{
16
    public function __construct(AttributeSet $attributes = null)
17
    {
18
        $this->attributes = $attributes ?? new AttributeSet();
19
        $this->tag = new EmptyTag('input', $attributes);
20
    }
21
22
    public function withAttribute(string $name, string $value = null): Input
23
    {
24
        if ($value) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $value of type null|string is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
25
            $attribute = new StandardAttribute($name, $value);
26
        } else {
27
            $attribute = new BooleanAttribute($name);
28
        }
29
30
        return new Input($this->attributes->add($attribute));
31
    }
32
33
    public function withType(string $type): Input
34
    {
35
        return $this->withAttribute('type', $type);
36
    }
37
38
    public function withAccept(string $fileTypes): Input
39
    {
40
        return $this->withAttribute('accept', $fileTypes);
41
    }
42
43
    public function withAutoComplete(string $mode = 'on'): Input
44
    {
45
        return $this->withAttribute('autocomplete', $mode);
46
    }
47
48
    public function withAutoFocus(): Input
49
    {
50
        return $this->withAttribute('autofocus');
51
    }
52
53
    public function withCapture(string $capture): Input
54
    {
55
        return $this->withAttribute('capture', $capture);
56
    }
57
58
    public function withChecked(): Input
59
    {
60
        return $this->withAttribute('checked');
61
    }
62
63
    public function withDisabled(): Input
64
    {
65
        return $this->withAttribute('disabled');
66
    }
67
68
    public function withForm(string $id): Input
69
    {
70
        return $this->withAttribute('form', $id);
71
    }
72
73
    public function withFormAction(string $url): Input
74
    {
75
        return $this->withAttribute('formaction', $url);
76
    }
77
78
    public function withFormEncType(string $encoding = 'application/x-www-form-urlencoded'): Input
79
    {
80
        return $this->withAttribute('formenctype', $encoding);
81
    }
82
83
    public function withFormMethod(string $method): Input
84
    {
85
        return $this->withAttribute('formmethod', $method);
86
    }
87
88
    public function withFormNoValidate(): Input
89
    {
90
        return $this->withAttribute('formnovalidate');
91
    }
92
93
    public function withFormTarget(string $target = '_self'): Input
94
    {
95
        return $this->withAttribute('formtarget', $target);
96
    }
97
98
    public function withHeight(int $pixels): Input
99
    {
100
        return $this->withAttribute('height', $pixels);
101
    }
102
103
    public function withInputMode(string $mode): Input
104
    {
105
        return $this->withAttribute('inputmode', $mode);
106
    }
107
108
    public function withList(string $dataListId): Input
109
    {
110
        return $this->withAttribute('list', $dataListId);
111
    }
112
113
    public function withMax(string $max): Input
114
    {
115
        return $this->withAttribute('max', $max);
116
    }
117
118
    public function withMaxLength(string $max): Input
119
    {
120
        return $this->withAttribute('maxlength', $max);
121
    }
122
123
    public function withMin(string $min): Input
124
    {
125
        return $this->withAttribute('min', $min);
126
    }
127
128
    public function withMinLength(string $min): Input
129
    {
130
        return $this->withAttribute('minlength', $min);
131
    }
132
133
    public function withMultiple(): Input
134
    {
135
        return $this->withAttribute('multiple');
136
    }
137
138
    public function withName(string $name): Input
139
    {
140
        return $this->withAttribute('name', $name);
141
    }
142
143
    public function withPattern(string $regex): Input
144
    {
145
        return $this->withAttribute('pattern', $regex);
146
    }
147
148
    public function withPlaceholder(string $placeholder): Input
149
    {
150
        return $this->withAttribute('placeholder', $placeholder);
151
    }
152
153
    public function withReadOnly(): Input
154
    {
155
        return $this->withAttribute('readonly');
156
    }
157
158
    public function withRequired(): Input
159
    {
160
        return $this->withAttribute('required');
161
    }
162
163
    public function withSelectionDirection(string $direction = 'forward'): Input
164
    {
165
        return $this->withAttribute('selectionDirection', $direction);
166
    }
167
168
    public function withSelectionEnd(string $end): Input
169
    {
170
        return $this->withAttribute('selectionEnd', $end);
171
    }
172
173
    public function withSelectionStart(string $start): Input
174
    {
175
        return $this->withAttribute('selectionStart', $start);
176
    }
177
178
    public function withSize(int $size): Input
179
    {
180
        return $this->withAttribute('size', $size);
181
    }
182
183
    public function withSpellCheck(string $check = 'default'): Input
184
    {
185
        return $this->withAttribute('spellcheck', $check);
186
    }
187
188
    public function withSrc(string $url): Input
189
    {
190
        return $this->withAttribute('src', $url);
191
    }
192
193
    public function withStep(string $increment): Input
194
    {
195
        return $this->withAttribute('step', $increment);
196
    }
197
198
    public function withValue(string $value): Input
199
    {
200
        return $this->withAttribute('value', $value);
201
    }
202
203
    public function withWidth(int $width): Input
204
    {
205
        return $this->withAttribute('width', $width);
206
    }
207
}
208