Skip to content

Commit 03a824a

Browse files
bug #19803 [WebProfilerBundle] Fix infinite loop in JS (nicolas-grekas)
This PR was merged into the 3.2-dev branch. Discussion ---------- [WebProfilerBundle] Fix infinite loop in JS | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes (master only) | Tests pass? | yes | License | MIT For some reason, I ended up having this while loop infinitely. Commits ------- 68b6c32 [WebProfilerBundle] Fix infinite loop in JS
2 parents 16c5c76 + 68b6c32 commit 03a824a

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_js.html.twig

+7-4
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@
1616
function(xhr, el) {
1717
1818
/* Evaluate embedded scripts inside the toolbar */
19-
var rx=/<script>(.*?)<\/script>/g, s;
20-
while (s = rx.exec(el.innerHTML)) {eval(s[1]);};
19+
var i, scripts = [].slice.call(el.querySelectorAll('script'));
20+
21+
for (i = 0; i < scripts.length; ++i) {
22+
eval(scripts[i].firstChild.nodeValue);
23+
}
2124
2225
el.style.display = -1 !== xhr.responseText.indexOf('sf-toolbarreset') ? 'block' : 'none';
2326
@@ -38,8 +41,8 @@
3841
Sfjs.renderAjaxRequests();
3942
4043
/* Handle toolbar-info position */
41-
var toolbarBlocks = document.querySelectorAll('.sf-toolbar-block');
42-
for (var i = 0; i < toolbarBlocks.length; i += 1) {
44+
var toolbarBlocks = [].slice.call(el.querySelectorAll('.sf-toolbar-block'));
45+
for (i = 0; i < toolbarBlocks.length; ++i) {
4346
toolbarBlocks[i].onmouseover = function () {
4447
var toolbarInfo = this.querySelectorAll('.sf-toolbar-info')[0];
4548
var pageWidth = document.body.clientWidth;

0 commit comments

Comments
 (0)