Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a95503a

Browse files
committed
bug symfony#9643 [WebProfilerBundle] Fixed js escaping in time.html.twig (hason)
This PR was merged into the 2.2 branch. Discussion ---------- [WebProfilerBundle] Fixed js escaping in time.html.twig | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | For some event names I received the JavaScript error: ```Uncaught SyntaxError: Unexpected token ILLEGAL``` Commits ------- 4828350 [WebProfilerBundle] Fixed js escaping in time.html.twig
2 parents 9ec6a9c + 4828350 commit a95503a

File tree

1 file changed

+7
-3
lines changed
  • src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector

1 file changed

+7
-3
lines changed

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/time.html.twig

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
{% endfor %}
9292
{% endif %}
9393

94-
<script type="text/javascript">//<![CDATA[
94+
<script type="text/javascript">{% autoescape 'js' %}//<![CDATA[
9595
/**
9696
* In-memory key-value cache manager
9797
*/
@@ -428,10 +428,11 @@
428428
canvasAutoUpdateOnThresholdChange(null);
429429
}, 50);
430430
431-
//]]></script>
431+
//]]>{% endautoescape %}</script>
432432
{% endblock %}
433433

434434
{% macro dump_request_data(token, profile, events, origin) %}
435+
{% autoescape 'js' %}
435436
{% from _self import dump_events %}
436437
{
437438
"id": "{{ token }}",
@@ -440,13 +441,15 @@
440441
{{ dump_events(events) }}
441442
]
442443
}
444+
{% endautoescape %}
443445
{% endmacro %}
444446

445447
{% macro dump_events(events) %}
448+
{% autoescape 'js' %}
446449
{% for name, event in events %}
447450
{% if '__section__' != name %}
448451
{
449-
"name": "{{ name|replace({"\\": "\\\\"}) }}",
452+
"name": "{{ name }}",
450453
"category": "{{ event.category }}",
451454
"origin": {{ "%F"|format(event.origin) }},
452455
"starttime": {{ "%F"|format(event.starttime) }},
@@ -461,6 +464,7 @@
461464
}{{ loop.last ? '' : ',' }}
462465
{% endif %}
463466
{% endfor %}
467+
{% endautoescape %}
464468
{% endmacro %}
465469

466470
{% macro display_timeline(id, events, colors) %}

0 commit comments

Comments
 (0)