81
81
{% - endif -%}
82
82
<div class =" inner_cell" >
83
83
<div class =" text_cell_render border-box-sizing rendered_html" >
84
- {{ cell.source | markdown2html | strip_files_prefix | clean_html }}
84
+ {% - if resources .should_sanitize_html %}
85
+ {% - set html_value =cell .source | markdown 2html | strip_files_prefix | clean_html -%}
86
+ {% - else %}
87
+ {% - set html_value =cell .source | markdown 2html | strip_files_prefix -%}
88
+ {% - endif %}
89
+ {{ html_value }}
85
90
</div >
86
91
</div >
87
92
</div >
@@ -133,23 +138,33 @@ unknown type {{ cell.type }}
133
138
134
139
{% block data_html scoped -%}
135
140
<div class =" output_html rendered_html output_subarea {{ extra_class }}" >
141
+ {% - if resources .should_sanitize_html %}
142
+ {% - set html_value =output .data ['text/html' ] | clean_html -%}
143
+ {% - else %}
144
+ {% - set html_value =output .data ['text/html' ] -%}
145
+ {% - endif %}
136
146
{% - if output .get ('metadata' , {}).get ('text/html' , {}).get ('isolated' ) -%}
137
147
<iframe
138
148
class =" isolated-iframe"
139
149
style =" height :520px ; width :100% ; margin :0 ; padding : 0 "
140
150
frameborder =" 0"
141
151
scrolling =" auto"
142
- src =" data:text/html;base64,{{output.data['text/html'] | text_base64}}" >
152
+ src =" data:text/html;base64,{{ html_value | text_base64 }}" >
143
153
</iframe >
144
154
{% - else -%}
145
- {{ output.data['text/html '] }}
155
+ {{ html_value }}
146
156
{% - endif -%}
147
157
</div >
148
158
{% - endblock data_html %}
149
159
150
160
{% block data_markdown scoped -%}
161
+ {% - if resources .should_sanitize_html %}
162
+ {% - set html_value =output .data ['text/markdown' ] | markdown 2html | clean_html -%}
163
+ {% - else %}
164
+ {% - set html_value =output .data ['text/markdown' ] | markdown 2html -%}
165
+ {% - endif %}
151
166
<div class =" output_markdown rendered_html output_subarea {{ extra_class }}" >
152
- {{ output.data['text/markdown '] | markdown2html }}
167
+ {{ html_value }}
153
168
</div >
154
169
{% - endblock data_markdown %}
155
170
@@ -234,14 +249,17 @@ alt="{{ alttext | escape_html }}"
234
249
{% - block data_javascript scoped %}
235
250
{% set div_id = uuid 4() %}
236
251
<div id =" {{ div_id }}" class =" output_subarea output_javascript {{ extra_class }}" >
252
+ {% - if not resources .should_sanitize_html %}
237
253
<script type =" text/javascript" >
238
254
var element = $ (' #{{ div_id }}' );
239
255
{{ output .data [' application/javascript' ] }}
240
256
</script >
257
+ {% - endif %}
241
258
</div >
242
259
{% - endblock -%}
243
260
244
261
{% - block data_widget_view scoped %}
262
+ {% - if not resources .should_sanitize_html %}
245
263
{% set div_id = uuid 4() %}
246
264
{% set datatype_list = output .data | filter_data_type %}
247
265
{% set datatype = datatype_list [0]%}
@@ -253,14 +271,17 @@ var element = $('#{{ div_id }}');
253
271
{{ output .data [datatype] | json_dumps | escape_html }}
254
272
</script >
255
273
</div >
274
+ {% - endif %}
256
275
{% - endblock data_widget_view -%}
257
276
258
277
{% - block footer %}
278
+ {% - if not resources .should_sanitize_html %}
259
279
{% set mimetype = 'application/vnd.jupyter.widget-state+json' %}
260
280
{% if mimetype in nb .metadata .get ("widgets" ,{})%}
261
281
<script type =" {{ mimetype }}" >
262
- {{ nb .metadata .widgets [mimetype] | json_dumps | clean_html }}
282
+ {{ nb .metadata .widgets [mimetype] | json_dumps | escape_html }}
263
283
</script >
264
284
{% endif %}
285
+ {% - endif %}
265
286
{{ super() }}
266
287
{% - endblock footer -%}
0 commit comments