tburry /
pquery
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * @author Niels A.D. |
||
| 4 | * @author Todd Burry <[email protected]> |
||
| 5 | * @copyright 2010 Niels A.D., 2014 Todd Burry |
||
| 6 | * @license http://opensource.org/licenses/LGPL-2.1 LGPL-2.1 |
||
| 7 | * @package pQuery |
||
| 8 | */ |
||
| 9 | |||
| 10 | namespace pQuery; |
||
| 11 | |||
| 12 | /** |
||
| 13 | * Converts a XML document to an array |
||
| 14 | */ |
||
| 15 | class XML2ArrayParser extends HtmlParserBase {
|
||
| 16 | |||
| 17 | /** |
||
| 18 | * Holds the document structure |
||
| 19 | * @var array array('name' => 'tag', 'attrs' => array('attr' => 'val'), 'childen' => array())
|
||
| 20 | */ |
||
| 21 | var $root = array( |
||
| 22 | 'name' => '', |
||
| 23 | 'attrs' => array(), |
||
| 24 | 'children' => array() |
||
| 25 | ); |
||
| 26 | |||
| 27 | /** |
||
| 28 | * Current parsing hierarchy |
||
| 29 | * @var array |
||
| 30 | * @access private |
||
| 31 | */ |
||
| 32 | var $hierarchy = array(); |
||
| 33 | |||
| 34 | protected function parse_hierarchy($self_close) {
|
||
| 35 | if ($this->status['closing_tag']) {
|
||
|
0 ignored issues
–
show
|
|||
| 36 | $found = false; |
||
| 37 | for ($count = count($this->hierarchy), $i = $count - 1; $i >= 0; $i--) {
|
||
| 38 | if (strcasecmp($this->hierarchy[$i]['name'], $this->status['tag_name']) === 0) {
|
||
|
0 ignored issues
–
show
The property
status cannot be accessed from this context as it is declared private in class pQuery\HtmlParserBase.
This check looks for access to properties that are not accessible from the current context. If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class. Loading history...
|
|||
| 39 | |||
| 40 | for($ii = ($count - $i - 1); $ii >= 0; $ii--) {
|
||
| 41 | $e = array_pop($this->hierarchy); |
||
| 42 | if ($ii > 0) {
|
||
| 43 | $this->addError('Closing tag "'.$this->status['tag_name'].'" while "'.$e['name'].'" is not closed yet');
|
||
|
0 ignored issues
–
show
The property
status cannot be accessed from this context as it is declared private in class pQuery\HtmlParserBase.
This check looks for access to properties that are not accessible from the current context. If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class. Loading history...
|
|||
| 44 | } |
||
| 45 | } |
||
| 46 | |||
| 47 | $found = true; |
||
| 48 | break; |
||
| 49 | } |
||
| 50 | } |
||
| 51 | |||
| 52 | if (!$found) {
|
||
| 53 | $this->addError('Closing tag "'.$this->status['tag_name'].'" which is not open');
|
||
|
0 ignored issues
–
show
The property
status cannot be accessed from this context as it is declared private in class pQuery\HtmlParserBase.
This check looks for access to properties that are not accessible from the current context. If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class. Loading history...
|
|||
| 54 | } |
||
| 55 | } else {
|
||
| 56 | $tag = array( |
||
| 57 | 'name' => $this->status['tag_name'], |
||
|
0 ignored issues
–
show
The property
status cannot be accessed from this context as it is declared private in class pQuery\HtmlParserBase.
This check looks for access to properties that are not accessible from the current context. If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class. Loading history...
|
|||
| 58 | 'attrs' => $this->status['attributes'], |
||
|
0 ignored issues
–
show
The property
status cannot be accessed from this context as it is declared private in class pQuery\HtmlParserBase.
This check looks for access to properties that are not accessible from the current context. If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class. Loading history...
|
|||
| 59 | 'children' => array() |
||
| 60 | ); |
||
| 61 | if ($this->hierarchy) {
|
||
|
0 ignored issues
–
show
The expression
$this->hierarchy of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent. Consider making the comparison explicit by using Loading history...
|
|||
| 62 | $current =& $this->hierarchy[count($this->hierarchy) - 1]; |
||
| 63 | $current['children'][] = $tag; |
||
| 64 | $tag =& $current['children'][count($current['children']) - 1]; |
||
| 65 | unset($current['tagData']); |
||
| 66 | } else {
|
||
| 67 | $this->root = $tag; |
||
| 68 | $tag =& $this->root; |
||
| 69 | $self_close = false; |
||
| 70 | } |
||
| 71 | if (!$self_close) {
|
||
| 72 | $this->hierarchy[] =& $tag; |
||
| 73 | } |
||
| 74 | } |
||
| 75 | } |
||
| 76 | |||
| 77 | function parse_tag_default() {
|
||
| 78 | if (!parent::parse_tag_default()) {return false;}
|
||
| 79 | |||
| 80 | if ($this->status['tag_name'][0] !== '?') {
|
||
|
0 ignored issues
–
show
The property
status cannot be accessed from this context as it is declared private in class pQuery\HtmlParserBase.
This check looks for access to properties that are not accessible from the current context. If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class. Loading history...
|
|||
| 81 | $this->parse_hierarchy(($this->status['self_close']) ? true : null); |
||
|
0 ignored issues
–
show
The property
status cannot be accessed from this context as it is declared private in class pQuery\HtmlParserBase.
This check looks for access to properties that are not accessible from the current context. If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class. Loading history...
|
|||
| 82 | } |
||
| 83 | return true; |
||
| 84 | } |
||
| 85 | |||
| 86 | function parse_text() {
|
||
| 87 | parent::parse_text(); |
||
| 88 | if (($this->status['text'] !== '') && $this->hierarchy) {
|
||
|
0 ignored issues
–
show
The property
status cannot be accessed from this context as it is declared private in class pQuery\HtmlParserBase.
This check looks for access to properties that are not accessible from the current context. If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class. Loading history...
The expression
$this->hierarchy of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent. Consider making the comparison explicit by using Loading history...
|
|||
| 89 | $current =& $this->hierarchy[count($this->hierarchy) - 1]; |
||
| 90 | if (!$current['children']) {
|
||
| 91 | $current['tagData'] = $this->status['text']; |
||
|
0 ignored issues
–
show
The property
status cannot be accessed from this context as it is declared private in class pQuery\HtmlParserBase.
This check looks for access to properties that are not accessible from the current context. If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class. Loading history...
|
|||
| 92 | } |
||
| 93 | } |
||
| 94 | } |
||
| 95 | |||
| 96 | function parse_all() {
|
||
| 97 | return ((parent::parse_all()) ? $this->root : false); |
||
|
0 ignored issues
–
show
|
|||
| 98 | } |
||
| 99 | } |
||
| 100 | |||
| 101 | ?> |
This check looks for access to properties that are not accessible from the current context.
If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.