-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy path_core-http-query-string-errors.php
41 lines (36 loc) · 1.08 KB
/
_core-http-query-string-errors.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
/*
* Plugin Name: Log not WordPress friendly URL query strings
* Plugin URI: https://github.com/szepeviktor/wordpress-website-lifecycle
*/
add_action(
'parse_request',
static function () {
if (empty($_SERVER['QUERY_STRING'])) {
return;
}
if (strpos($_SERVER['QUERY_STRING'], '+') !== false) {
error_log(sprintf(
'Non-WordPress query string: plus_encoded_whitespace ("%s")',
$_SERVER['QUERY_STRING']
));
return;
}
if (strpos($_SERVER['QUERY_STRING'], '*') !== false) {
error_log(sprintf(
'Non-WordPress query string: not_encoded_asterisk ("%s")',
$_SERVER['QUERY_STRING']
));
return;
}
if (preg_match('/%[[:xdigit:]]?[a-f]/', $_SERVER['QUERY_STRING']) === 1) {
error_log(sprintf(
'Non-WordPress query string: lower_case_hexadecimal_digit ("%s")',
$_SERVER['QUERY_STRING']
));
return;
}
},
0,
0
);