Problem/Motivation

Users sometimes want to use inline HTML in uploaded tables.

Steps to reproduce

Proposed resolution

Allow cell content to be rendered as #markup

Remaining tasks

User interface changes

This could be added as an optional configuration, we have a patch to just turn it on across the board.

API changes

Data model changes

CommentFileSizeAuthor
task-DC-1540-allow-html-data-table.patch679 bytesmciver87
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mciver87 created an issue. See original summary.

zengenuity’s picture

I think if we add this, it shouldn't use a #markup render array. That's too permissive. While that is filtered for XSS, it's not filtered for other restricted tags on the site, nor are any filters run to make sure the HTML is valid. You could have unclosed tags, for example, that would break the site formatting.

I think to add this, we would need two things:

1. Switch to using #processed_text instead of #markup.

2. Add a configuration option on the field formatter that allows you to select whether the contents of the CSV file should be rendered as plain text or formatted text. If formatted text is chosen, then you should be required to pick what text format to use from the available text formats on the website. That would then be used as the #format value when we render the results with #processed_text. We can use #plain_text if the plain text option is chosen.

geoffreyr’s picture

I've got a case where I have a CSV with a lot of line breaks in the cells that I'd like to convert to HTML <br /> markup (nl2br style). This feature might allow for what I want to achieve, so I'll see if it's possible to render out the cells with a text filter set.

geoffreyr’s picture

Assigned: mciver87 » Unassigned
Status: Active » Needs review

MR available for review.

zengenuity’s picture

Status: Needs review » Fixed

This looks good. Merged.

Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.