Phase 3: fix form editor issue
This commit is contained in:
@@ -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,
|
||||||
|
|||||||
Reference in New Issue
Block a user