Skip to content

Fix the select option labels and HTML encoded settings in the back end - #37

Merged
markocupic merged 1 commit into
5.5.xfrom
fix-select-option-labels
Oct 10, 2026
Merged

markocupic merged 1 commit into
5.5.xfrom
fix-select-option-labels

Conversation

@markocupic

Copy link
Copy Markdown
Owner

Summary

Fixes the broken select options in the back end, plus the other encoding problems I found while checking the bundle.

Field option labels (screenshot bug)

optionsCbGetTableColumns() returned labels like firstname <span class="ifcb-sql-descr">[{"type":"string",…}]</span>. Contao escapes option labels, so the select (choices) showed the raw HTML and JSON. These options are used by:

  • matchBy
  • skipValidationFields
  • the field_name columns of the selectedFields and mapValues row wizards

The labels are now plain text:

  • firstname [string(255), default: '']
  • id [integer, unsigned, autoincrement]
  • title [varchar(255) NOT NULL default '']

The new formatSqlDefinition() method turns the array SQL definition into readable text.

Other encoding issues

  • Transform values (mapValues): In Contao 5 back end input is stored HTML encoded. A value like A&B was stored as A&amp;B, so it never matched the raw CSV value, and transform_to was written to the record still encoded.
    • The values are now decoded when they are compared and applied, so existing records work without being saved again.
    • The two text fields also get decodeEntities.
    • The lowercase and uppercase options now use the multibyte functions mb_strtolower/mb_strtoupper (umlauts) and no longer emit undefined-key warnings.
  • Field separator and field enclosure:
    • The values are decoded before they are passed to League CSV. This affects the factory, MountAppAjaxController and the header lookup in the data container.
    • fieldSeparator now uses useRawRequestData, like fieldEnclosure already did. Otherwise characters like & would be stored as &amp; and fail the maxlength of 1.
    • The header lookup now also respects the configured enclosure.
  • import.html.twig: The confirm message and the app URL/token are inside JavaScript strings but were HTML-escaped or |raw. They now use |e('js'). Previously an apostrophe in a translation broke the JavaScript.
  • DCA: ImportFromCSV::class is changed to ImportFromCsv::class. The callback class name was in the wrong case.

Tests

New ImportFromCsvTest for the plain-text label. CI is green on Contao 5.7.14, 5.7.15 and 6.0.4.

Suggested release: 5.5.1.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Jb7ViNYJwLjr2Y34g8aAoK


Generated by Claude Code

- Do not add HTML to the field option labels; Contao escapes option labels,
  so the <span> and the JSON encoded SQL definition were shown as text.
  The SQL definition is now appended as readable plain text.
- Decode the HTML encoded field separator, field enclosure and the values of
  the "transform values" mapping (Contao 5 stores back end input encoded)
- Escape the confirm message and the app URL for JavaScript in the import template
- Fix the case of the ImportFromCsv callback class in the DCA

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Jb7ViNYJwLjr2Y34g8aAoK
@markocupic
markocupic merged commit 1703a00 into 5.5.x Oct 10, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant