@@ -115,9 +115,9 @@ protected function addCSS(string $css, string $hook = 'add-css')
115
115
* @param string $action
116
116
* @param bool
117
117
*/
118
- protected function verifyToken (string $ token = '' , string $ source = '' )
118
+ protected function verifyToken (? string $ token = null , ? string $ source = null )
119
119
{
120
- if ( ! empty ( $ token) ) {
120
+ if ( $ token ) {
121
121
122
122
$ transient = new Transient ();
123
123
$ data = (string )$ transient ->getTemp ($ token );
@@ -154,7 +154,7 @@ protected function verifyToken(string $token = '', string $source = '')
154
154
* Verify current request.
155
155
*
156
156
* @access protected
157
- * @param bool $force Token validation
157
+ * @param bool $force, Token validation
158
158
* @return void
159
159
*/
160
160
protected function verifyRequest (bool $ force = false )
@@ -189,31 +189,38 @@ protected function verifyRequest(bool $force = false)
189
189
190
190
/**
191
191
* Sanitize current request.
192
- *
192
+ *
193
193
* @access protected
194
- * @param bool $verify Request
195
- * @param bool $force Token validation
196
- * @return mixed
194
+ * @param bool $verify, Request
195
+ * @param bool $force, Token validation
196
+ * @return array
197
197
*/
198
- protected function sanitizeRequest (bool $ verify = true , bool $ force = false )
198
+ protected function sanitizeRequest (bool $ verify = true , bool $ force = false ) : array
199
199
{
200
- if ( $ verify ) $ this ->verifyRequest ($ force );
201
-
202
200
$ request = $ this ->getRequest ();
203
- $ excepts = $ this ->applyFilter ('sanitize-request ' , [
204
- 'submit ' ,
205
- '--token ' ,
206
- '--source ' ,
207
- '--ignore '
208
- ]);
201
+ $ excepts = [
202
+ 'PHPSESSID ' , 'COOKIES '
203
+ ];
204
+
205
+ if ( !$ force ) {
206
+ $ excepts = $ this ->mergeArray ([
207
+ 'submit ' , '--token ' , '--source ' , '--ignore '
208
+ ], $ excepts );
209
+ }
210
+
211
+ if ( $ verify ) {
212
+ $ this ->verifyRequest ($ force );
213
+ }
214
+
215
+ $ excepts = $ this ->applyFilter ('sanitize-request ' , $ excepts );
209
216
210
217
foreach ($ excepts as $ except ) {
211
218
if ( isset ($ request [$ except ]) ) {
212
219
unset($ request [$ except ]);
213
220
}
214
221
}
215
222
216
- return $ request ;
223
+ return $ request ?: [] ;
217
224
}
218
225
219
226
/**
0 commit comments