Issues (174)

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.

classes/PHPTAL/Dom/Attr.php (15 issues)

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
 * PHPTAL templating engine
4
 *
5
 * PHP Version 5
6
 *
7
 * @category HTML
8
 * @package  PHPTAL
9
 * @author   Laurent Bedubourg <[email protected]>
10
 * @author   Kornel Lesiński <[email protected]>
11
 * @license  http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License
12
 * @version  SVN: $Id$
13
 * @link     http://phptal.org/
14
 */
15
16
/**
17
 * node that represents element's attribute
18
 *
19
 * @package PHPTAL
20
 * @subpackage Dom
21
 */
22
class PHPTAL_Dom_Attr
23
{
24
    private $value_escaped, $qualified_name, $namespace_uri, $encoding;
25
    /**
26
     * attribute's value can be overriden with a variable
27
     */
28
    private $phpVariable;
29
    const HIDDEN = -1;
30
    const NOT_REPLACED = 0;
31
    const VALUE_REPLACED = 1;
32
    const FULLY_REPLACED = 2;
33
    private $replacedState = 0;
34
35
    /**
36
     * @param string $qualified_name attribute name with prefix
37
     * @param string $namespace_uri full namespace URI or empty string
38
     * @param string $value_escaped value with HTML-escaping
39
     * @param string $encoding character encoding used by the value
40
     */
41
    function __construct($qualified_name, $namespace_uri, $value_escaped, $encoding)
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
42
    {
43
        $this->value_escaped = $value_escaped;
44
        $this->qualified_name = $qualified_name;
45
        $this->namespace_uri = $namespace_uri;
46
        $this->encoding = $encoding;
47
    }
48
49
    /**
50
     * get character encoding used by this attribute.
51
     */
52
    public function getEncoding()
53
    {
54
        return $this->encoding;
55
    }
56
57
    /**
58
     * get full namespace URI. "" for default namespace.
59
     */
60
    function getNamespaceURI()
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
61
    {
62
        return $this->namespace_uri;
63
    }
64
65
    /**
66
     * get attribute name including namespace prefix, if any
67
     */
68
    function getQualifiedName()
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
69
    {
70
        return $this->qualified_name;
71
    }
72
73
    /**
74
     * get "foo" of "ns:foo" attribute name
75
     */
76
    function getLocalName()
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
77
    {
78
        $n = explode(':', $this->qualified_name, 2);
79
        return end($n);
80
    }
81
82
    /**
83
     * Returns true if this attribute is ns declaration (xmlns="...")
84
     *
85
     * @return bool
86
     */
87
    function isNamespaceDeclaration()
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
88
    {
89
        return preg_match('/^xmlns(?:$|:)/', $this->qualified_name);
90
    }
91
92
93
    /**
94
     * get value as plain text
95
     *
96
     * @return string
97
     */
98
    function getValue()
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
99
    {
100
        return html_entity_decode($this->value_escaped, ENT_QUOTES, $this->encoding);
101
    }
102
103
    /**
104
     * set plain text as value
105
     */
106
    function setValue($val)
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
107
    {
108
        $this->value_escaped = htmlspecialchars($val, ENT_QUOTES, $this->encoding);
109
    }
110
111
    /**
112
     * Depends on replaced state.
113
     * If value is not replaced, it will return it with HTML escapes.
114
     *
115
     * @see getReplacedState()
116
     * @see overwriteValueWithVariable()
117
     */
118
    function getValueEscaped()
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
119
    {
120
        return $this->value_escaped;
121
    }
122
123
    /**
124
     * Set value of the attribute to this exact string.
125
     * String must be HTML-escaped and use attribute's encoding.
126
     *
127
     * @param string $value_escaped new content
128
     */
129
    function setValueEscaped($value_escaped)
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
130
    {
131
        $this->replacedState = self::NOT_REPLACED;
132
        $this->value_escaped = $value_escaped;
133
    }
134
135
    /**
136
     * set PHP code as value of this attribute. Code is expected to echo the value.
137
     */
138
    private function setPHPCode($code)
139
    {
140
        $this->value_escaped = '<?php '.$code." ?>\n";
141
    }
142
143
    /**
144
     * hide this attribute. It won't be generated.
145
     */
146
    function hide()
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
147
    {
148
        $this->replacedState = self::HIDDEN;
149
    }
150
151
    /**
152
     * generate value of this attribute from variable
153
     */
154
    function overwriteValueWithVariable($phpVariable)
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
155
    {
156
        $this->replacedState = self::VALUE_REPLACED;
157
        $this->phpVariable = $phpVariable;
158
        $this->setPHPCode('echo '.$phpVariable);
159
    }
160
161
    /**
162
     * generate complete syntax of this attribute using variable
163
     */
164
    function overwriteFullWithVariable($phpVariable)
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
165
    {
166
        $this->replacedState = self::FULLY_REPLACED;
167
        $this->phpVariable = $phpVariable;
168
        $this->setPHPCode('echo '.$phpVariable);
169
    }
170
171
    /**
172
     * use any PHP code to generate this attribute's value
173
     */
174
    function overwriteValueWithCode($code)
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
175
    {
176
        $this->replacedState = self::VALUE_REPLACED;
177
        $this->phpVariable = null;
178
        $this->setPHPCode($code);
179
    }
180
181
    /**
182
     * if value was overwritten with variable, get its name
183
     */
184
    function getOverwrittenVariableName()
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
185
    {
186
        return $this->phpVariable;
187
    }
188
189
    /**
190
     * whether getValueEscaped() returns real value or PHP code
191
     */
192
    function getReplacedState()
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
193
    {
194
        return $this->replacedState;
195
    }
196
}
197