Conditions | 5 |
Paths | 2 |
Total Lines | 27 |
Lines | 0 |
Ratio | 0 % |
Tests | 15 |
CRAP Score | 5 |
Changes | 0 |
1 | <?php |
||
15 | 6 | public function removeEvilAttributes($str) |
|
16 | { |
||
17 | // replace style-attribute, first (if needed) |
||
18 | 6 | if (stripos($str, 'style') !== false && in_array('style', $this->_evil_attributes_regex, true)) { |
|
19 | do { |
||
20 | 6 | $count = $temp_count = 0; |
|
21 | |||
22 | 6 | $str = (string)preg_replace('/(<[^>]+)(?<!\p{L})(style\s*=\s*"(?:[^"]*?)"|style\s*=\s*\'(?:[^\']*?)\')/iu', '$1' . $this->_replacement, $str, -1, $temp_count); |
|
23 | 6 | $count += $temp_count; |
|
24 | 6 | } while ($count); |
|
25 | 6 | } |
|
26 | |||
27 | 6 | $evil_attributes_string = implode('|', $this->_evil_attributes_regex); |
|
28 | |||
29 | do { |
||
30 | 6 | $count = $temp_count = 0; |
|
31 | |||
32 | // find occurrences of illegal attribute strings with and without quotes (042 ["] and 047 ['] are octal quotes) |
||
33 | 6 | $str = (string)preg_replace('/(.*)((?:<[^>]+)(?<!\p{L}))(?:' . $evil_attributes_string . ')(?:\s*=\s*)(?:(?:\'|\047)(?:.*?)(?:\'|\047)|(?:"|\042)(?:.*?)(?:"|\042))(.*)/ius', '$1$2' . $this->_replacement . '$3$4', $str, -1, $temp_count); |
|
34 | 6 | $count += $temp_count; |
|
35 | |||
36 | 6 | $str = (string)\preg_replace('/(.*)(<[^>]+)(?<!\p{L})(?:' . $evil_attributes_string . ')\s*=\s*(?:[^\s>]*)(.*)/ius', '$1$2' . $this->_replacement . '$3', $str, -1, $temp_count); |
|
37 | 6 | $count += $temp_count; |
|
38 | 6 | } while ($count); |
|
39 | |||
40 | 6 | return (string)$str; |
|
41 | } |
||
42 | |||
43 | } |
This check marks property names that have not been written in camelCase.
In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes
databaseConnectionString
.