You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Called before rendering the component. Override to perform operations that
@@ -309,6 +314,38 @@ def content_evaluated?
309
314
@__vc_content_evaluated
310
315
end
311
316
317
+
defmaybe_escape_html(text)
318
+
returntextifrequest && !request.format.html?
319
+
returntextiftext.blank?
320
+
321
+
iftext.html_safe?
322
+
text
323
+
else
324
+
yield
325
+
html_escape(text)
326
+
end
327
+
end
328
+
329
+
defsafe_render_template_for(variant)
330
+
ifcompiler.renders_template_for_variant?(variant)
331
+
render_template_for(variant)
332
+
else
333
+
maybe_escape_html(render_template_for(variant))do
334
+
Kernel.warn("WARNING: The #{self.class} component rendered HTML-unsafe output. The output will be automatically escaped, but you may want to investigate.")
335
+
end
336
+
end
337
+
end
338
+
339
+
defsafe_output_postamble
340
+
maybe_escape_html(output_postamble)do
341
+
Kernel.warn("WARNING: The #{self.class} component was provided an HTML-unsafe postamble. The postamble will be automatically escaped, but you may want to investigate.")
0 commit comments