File tree 4 files changed +24
-32
lines changed
nbconvert/exporters/tests
share/jupyter/nbconvert/templates
4 files changed +24
-32
lines changed Original file line number Diff line number Diff line change 159
159
{
160
160
"cell_type" : " code" ,
161
161
"execution_count" : null ,
162
- "id" : " d72e635a " ,
162
+ "id" : " ae4f574d " ,
163
163
"metadata" : {},
164
164
"outputs" : [
165
165
{
174
174
}
175
175
],
176
176
"source" : [" " ]
177
+ },
178
+ {
179
+ "cell_type" : " code" ,
180
+ "execution_count" : null ,
181
+ "id" : " w72e635a" ,
182
+ "metadata" : {},
183
+ "outputs" : [
184
+ {
185
+ "output_type" : " execute_result" ,
186
+ "data" : {
187
+ "application/vnd.jupyter.widget-view+json" : {"model_id" : " wid1" , "foo" : " \" </script><script>alert('output.data.application/vnd.jupyter.widget-view+json injection')//" }
188
+ },
189
+ "execution_count" : null ,
190
+ "metadata" : {}
191
+ }
192
+ ],
193
+ "source" : [" " ]
177
194
}
178
195
],
179
196
"metadata" : {
196
213
"version" : " 3.10.5"
197
214
},
198
215
"widgets" : {
199
- "application/vnd.jupyter.widget-state+json" : {"state" : " {} " , "foo" : " pwntester</script><script>alert('widgets');//" }
216
+ "application/vnd.jupyter.widget-state+json" : {"state" : { "wid1" : {}} , "foo" : " pwntester</script><script>alert('widgets');//" }
200
217
}
201
218
},
202
219
"nbformat" : 4 ,
Original file line number Diff line number Diff line change @@ -167,3 +167,6 @@ def test_javascript_injection(self):
167
167
# Check injection in image width/height
168
168
assert "<script>alert('output.metadata.width png injection')</script>" not in output
169
169
assert "<script>alert('output.metadata.height png injection')</script>" not in output
170
+
171
+ # Check injection in widget view
172
+ assert "<script>alert('output.data.application/vnd.jupyter.widget-view+json injection')" not in output
Original file line number Diff line number Diff line change @@ -241,20 +241,6 @@ var element = $('#{{ div_id }}');
241
241
</div >
242
242
{% - endblock -%}
243
243
244
- {% - block data_widget_state scoped %}
245
- {% set div_id = uuid 4() %}
246
- {% set datatype_list = output .data | filter_data_type %}
247
- {% set datatype = datatype_list [0]%}
248
- <div id =" {{ div_id }}" class =" output_subarea output_widget_state {{ extra_class }}" >
249
- <script type =" text/javascript" >
250
- var element = $ (' #{{ div_id }}' );
251
- </script >
252
- <script type =" {{ datatype }}" >
253
- {{ output .data [datatype] | json_dumps }}
254
- </script >
255
- </div >
256
- {% - endblock data_widget_state -%}
257
-
258
244
{% - block data_widget_view scoped %}
259
245
{% set div_id = uuid 4() %}
260
246
{% set datatype_list = output .data | filter_data_type %}
@@ -264,7 +250,7 @@ var element = $('#{{ div_id }}');
264
250
var element = $ (' #{{ div_id }}' );
265
251
</script >
266
252
<script type =" {{ datatype }}" >
267
- {{ output .data [datatype] | json_dumps }}
253
+ {{ output .data [datatype] | json_dumps | escape_html }}
268
254
</script >
269
255
</div >
270
256
{% - endblock data_widget_view -%}
Original file line number Diff line number Diff line change @@ -273,20 +273,6 @@ var element = document.getElementById('{{ div_id }}');
273
273
</div >
274
274
{% - endblock -%}
275
275
276
- {% - block data_widget_state scoped %}
277
- {% set div_id = uuid 4() %}
278
- {% set datatype_list = output .data | filter_data_type %}
279
- {% set datatype = datatype_list [0]%}
280
- <div id =" {{ div_id }}" class =" output_subarea output_widget_state {{ extra_class }}" >
281
- <script type =" text/javascript" >
282
- var element = document .getElementById (' {{ div_id }}' );
283
- </script >
284
- <script type =" {{ datatype }}" >
285
- {{ output .data [datatype] | json_dumps }}
286
- </script >
287
- </div >
288
- {% - endblock data_widget_state -%}
289
-
290
276
{% - block data_widget_view scoped %}
291
277
{% set div_id = uuid 4() %}
292
278
{% set datatype_list = output .data | filter_data_type %}
@@ -296,7 +282,7 @@ var element = document.getElementById('{{ div_id }}');
296
282
var element = document .getElementById (' {{ div_id }}' );
297
283
</script >
298
284
<script type =" {{ datatype }}" >
299
- {{ output .data [datatype] | json_dumps }}
285
+ {{ output .data [datatype] | json_dumps | escape_html }}
300
286
</script >
301
287
</div >
302
288
{% - endblock data_widget_view -%}
You can’t perform that action at this time.
0 commit comments