bobbingwide / oik-bwtrace

debug trace for WordPress
https://www.oik-plugins.com/oik-plugins/oik-bwtrace-debug-trace-for-wordpress/
GNU General Public License v2.0
6 stars 1 forks source link

Daily trace summary AJAX action field can contain commas #90

Open bobbingwide opened 4 years ago

bobbingwide commented 4 years ago

The following line in the daily trace summary file from oik-plugins.co.uk for 20200209 has a AJAX action which contains unescaped commas.

/plugins/download/?plugin=oik-bwtrace-debug-trace-for-wordpress&version=3.0.0-RC2&id=37451&action=download.%2C%29%2C%29%27%29%29%22%27,download.,),)\'))\"\',0.340538,7.3.14,1726,4709,400,44,464,57,34,20,19,0.010370969772339,,,,7588,45.227.255.149,0.340430,2020-02-09T02:15:51+00:00,Opera/9.80 (Windows NT 5.2; U; en) Presto/2.2.15 Version/10.00,GET

This causes problems for post processing of the daily trace summary files.

bobbingwide commented 1 day ago

I've changed the code to detect a comma in the action. If present it wraps the action in double quotes AND applies urlencode() against the action.

"/wordpress/plugins/download/?plugin=oik-bwtrace-debug-trace-for-wordpress&version=3.0.0-RC2&id=37451&action=download.%2C%29%2C%29%27%29%29%22%27,download","download.%2C%29%2C%29%5C%27%29%29%5C%22%5C%27%2Cdownload",2.126263,8.3.3,1285,4642,475,42,779,28,43,27,11,0.015740156173706,C:/apache/htdocs/wordpress/bwtrace3/bwtraces.loh.7,92,0,12043,127.0.0.1,2.126087,2024-09-17T16:12:44+00:00,Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML; like Gecko) Chrome/128.0.0.0 Safari/537.36,GET,200

bobbingwide commented 1 day ago

Having made the change I ran slog. The original output caused slog to produce a Too many columns message.

Count: 45 Too many columns: "/wordpress/plugins/download/?plugin=oik-bwtrace-debug-trace-for-wordpress&version=3.0.0-RC2&id=37451&action=download.%2C%29%2C%29%27%29%29%22%27,download",download.,),)\'))\"\',download,2.336032,8.3.3,1285,4642,484,42,790,28,43,27,13,0.082084655761719,C:/apache/htdocs/wordpress/bwtrace3/bwtraces.loh.3,92,0,12129,127.0.0.1,2.335801,2024-09-17T16:00:00+00:00,Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML; like Gecko) Chrome/128.0.0.0 Safari/537.36,GET,200 Deprecated: stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated in C:\apache\htdocs\wordpress\wp-content\plugins\slog\libs\class-vt-row-basic.php on line 248 Rows loaded: 45 Grouping: 45 Display: Count

I edited the daily trace summary and ran it again. The change appears to have resolved the problem.

bobbingwide commented 1 day ago

Note: the download/plugins request is interpreted by oik-plugins as an AJAX request. See oikp_lazy_redirect(). In this function, if DOING_AJAX is not already defined ( which is expected to be the case ) then it defines DOING_AJAX as true. This doesn't happen until after tracing has been invoked, which explains why the trace file for the request is suffixed .log.n rather than .ajax.n

bobbingwide commented 1 day ago

To support PHP 8.n we need to change the default value of action to an empty string, otherwise strpos() and urlencode() produce messages.