Phase 3: fix form editor issue

This commit is contained in:
2026-02-23 12:19:44 -05:00
parent 549a4e6278
commit 8daa83de4d
+5 -8
View File
@@ -385,12 +385,9 @@
</div> </div>
</div> </div>
{# Schema data is stored in a data-attribute and parsed with JSON.parse() in JS. {# Schema is injected via a typed script tag — tojson escapes </script> sequences
This avoids using |safe which bypasses Jinja2 auto-escaping and could allow so this is safe. The JS init reads window.__FORM_SCHEMA__ directly. #}
stored XSS if the sanitiser ever lets a malicious value through. #} <script type="application/json" id="schema-data">{{ form_schema | tojson }}</script>
<div id="schema-data"
data-schema="{{ form_schema | tojson }}"
style="display:none;"></div>
<!-- PROPERTIES --> <!-- PROPERTIES -->
<div class="props-panel"> <div class="props-panel">
@@ -494,8 +491,8 @@ function growSurface() {
// INIT // INIT
// ═══════════════════════════════════════════════════════════════════════════ // ═══════════════════════════════════════════════════════════════════════════
(function init() { (function init() {
// Retrieve schema from the data-attribute (safe — no |safe bypass needed) // Retrieve schema from the typed script tag (safe tojson escapes </script> sequences)
const raw = JSON.parse(document.getElementById('schema-data').dataset.schema || '[]'); const raw = JSON.parse(document.getElementById('schema-data').textContent || '[]');
if (Array.isArray(raw) && raw.length) { if (Array.isArray(raw) && raw.length) {
fields = raw.map(f => ({ fields = raw.map(f => ({
...f, ...f,