File tree Expand file tree Collapse file tree 3 files changed +16
-1
lines changed
debug_toolbar/templates/debug_toolbar/panels Expand file tree Collapse file tree 3 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ <h4>{% translate "Calls" %}</h4>
61
61
</ tr >
62
62
< tr class ="djUnselected djToggleDetails_{{ forloop.counter }} " id ="cacheDetails_{{ forloop.counter }} ">
63
63
< td colspan ="1 "> </ td >
64
- < td colspan ="5 "> < pre class ="djdt-stack "> {{ call.trace }}</ pre > </ td >
64
+ < td colspan ="5 "> < pre class ="djdt-stack "> {{ call.trace|safe }}</ pre > </ td >
65
65
</ tr >
66
66
{% endfor %}
67
67
</ tbody >
Original file line number Diff line number Diff line change @@ -128,6 +128,8 @@ def test_insert_content(self):
128
128
content = self .panel .content
129
129
self .assertIn ("café" , content )
130
130
self .assertValidHTML (content )
131
+ # ensure traces aren't escaped
132
+ self .assertIn ('<span class="djdt-path">' , content )
131
133
132
134
def test_generate_server_timing (self ):
133
135
self .assertEqual (len (self .panel .calls ), 0 )
Original file line number Diff line number Diff line change 2
2
3
3
from django .test import TestCase
4
4
from django .test .utils import override_settings
5
+ from django .utils .safestring import SafeData , mark_safe
5
6
6
7
from debug_toolbar import store
7
8
@@ -97,6 +98,18 @@ def test_panel(self):
97
98
self .store .save_panel ("bar" , "bar.panel" , {"a" : 1 })
98
99
self .assertEqual (self .store .panel ("bar" , "bar.panel" ), {"a" : 1 })
99
100
101
+ def test_serialize_safestring (self ):
102
+ before = {"string" : mark_safe ("safe" )}
103
+
104
+ self .store .save_panel ("bar" , "bar.panel" , before )
105
+ after = self .store .panel ("bar" , "bar.panel" )
106
+
107
+ self .assertFalse (type (before ["string" ]) is str )
108
+ self .assertTrue (isinstance (before ["string" ], SafeData ))
109
+
110
+ self .assertTrue (type (after ["string" ]) is str )
111
+ self .assertFalse (isinstance (after ["string" ], SafeData ))
112
+
100
113
101
114
class StubStore (store .BaseStore ):
102
115
pass
You can’t perform that action at this time.
0 commit comments