Commit c3c2bce
committed
ProperEscapingFunction: allow for comma's in first short open echo tag expression
Short open echo tags will act as an echo for the first expression and allow for passing multiple comma-separated parameters.
However, short open echo tags also allow for additional statements after, but those have to be full PHP statements, not expressions.
So, the `T_COMMA` token should be allowed and skipped over in the first expression, but not for subsequent statements following a short open echo tag.
`$phpcsFile->findStartOfStatement()` unfortunately is useless - even in its fixed-up form as will be in PHPCS 3.6.1-, as it will return the first token in the statement, which can be anything - variable, text string - without any indication of whether this is the start of a normal statement or a short open echo expression.
So, if we used that, we'd still need to walk back from every start of statement to the previous non-empty to see if it is the short open echo tag.
So to solve this conundrum, I've implemented a simple tracking system which will keep track of whether we have seen a short open echo tag and are within the first statement (expression) after this tag and will add the `T_COMMA` token if those conditions are fulfilled.
Fixes 6711 parent 23ec390 commit c3c2bce
File tree
3 files changed
+91
-34
lines changed- WordPressVIPMinimum
- Sniffs/Security
- Tests/Security
3 files changed
+91
-34
lines changedLines changed: 48 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
92 | 100 | | |
93 | 101 | | |
94 | 102 | | |
| |||
97 | 105 | | |
98 | 106 | | |
99 | 107 | | |
100 | | - | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
101 | 112 | | |
102 | 113 | | |
103 | 114 | | |
| |||
108 | 119 | | |
109 | 120 | | |
110 | 121 | | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
111 | 151 | | |
112 | 152 | | |
113 | 153 | | |
| |||
121 | 161 | | |
122 | 162 | | |
123 | 163 | | |
124 | | - | |
125 | | - | |
126 | | - | |
| 164 | + | |
| 165 | + | |
127 | 166 | | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
128 | 172 | | |
129 | 173 | | |
130 | 174 | | |
| |||
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
Lines changed: 32 additions & 30 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
58 | 60 | | |
59 | 61 | | |
60 | 62 | | |
| |||
0 commit comments