Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix display bugs in profiling #26731

Merged
merged 3 commits into from
Dec 9, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions tools/profiling/Profiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,12 @@ public function processData()
$queryRow['filesort'] = true;
}

foreach ($explain as $row) {
$queryRow['rows'] *= (int) $row['rows'];
if (is_array($explain)) {
foreach ($explain as $row) {
$queryRow['rows'] *= (int) $row['rows'];
}
} else {
$queryRow['rows'] = 'N/A';
}

if (stristr($data['query'], 'group by') && !preg_match('/(avg|count|min|max|group_concat|sum)\s*\(/i', $data['query'])) {
Expand Down
2 changes: 1 addition & 1 deletion tools/profiling/templates/doubles.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
{sql_queries data=$nb}
</td>
<td class="pre">
<pre>{$q}</pre>
<pre>{$q nofilter}</pre>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eternoendless @PierreRambaud
$q always contains HTML, for highlighting the values replaces by XX. If you feel that nofilter could be dangerous, then we need another way to highlight the blue text.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, PR updated. The nofilter is not really needed here, the code added is useless and I can add an XSS because of this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

XSS inside the query coming from the software in the profiler displayed when the developer explicitly tells the application to do it? 🤔

</td>
</tr>
{/if}
Expand Down
2 changes: 1 addition & 1 deletion tools/profiling/templates/functions/load-time.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
{elseif $data > 0.8}
<span class="warning">{round($data * 1000)}</span>
{else}
<span class="success">{round($data * 1000)}</span>
<span class="success">{sprintf('%01.3f', $data * 1000)}</span>
{/if}
ms
{/function}
4 changes: 2 additions & 2 deletions tools/profiling/templates/stopwatch.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<tr>
<td class="pre"><pre>{preg_replace("/(^[\s]*)/m", "", htmlspecialchars($data['query'], ENT_NOQUOTES, 'utf-8', false))}</pre></td>
<td data-value="{$data['time']}">
{load_time data=($data['time'] * 1000)}
{load_time data=($data['time'])}
</td>

<td>{$data['rows']}</td>
Expand All @@ -63,7 +63,7 @@
</td>
<td data-value="{$data['location']}">
<a href="javascript:void(0);" onclick="$('#callstack_{$callstack_md5}').toggle();">{$data['location']}</a>
<div id="callstack_{$callstack_md5}" style="display:none">{implode('<br>', $data['stack'])}</div>
<div id="callstack_{$callstack_md5}" style="display:none">{implode('<br>', $data['stack']) nofilter}</div>
</td>
</tr>
{/foreach}
Expand Down