Problem/Motivation

In configuration manager segment html tags is visible

See screenshot:

Steps to recreate:
Go to /admin/people/permissions
Scroll down the page to see the HTML tags

Proposed resolution

Remove/hide tags

Remaining tasks

see above

User interface changes

see above

API changes

N/A

Original report by @username

N/A

Comments

roaldumandal’s picture

Title: HTML elements exposed in permission page » HTML tag is visible in permission page
Issue summary: View changes
akalata’s picture

akalata’s picture

haza’s picture

Version: 8.0.0-alpha14 » 8.0.x-dev
Status: Active » Needs review
StatusFileSize
new1.58 KB

Small patch attached to implement the "inline_template" type.

haza’s picture

Assigned: roaldumandal » Unassigned
heiket’s picture

heiket’s picture

Updated the issue summary to match template, added screenshot, confirmed issue.

heiket’s picture

Assigned: Unassigned » heiket
Issue tags: +Drupal8NZ
StatusFileSize
new87.39 KB

Tested Patch in #4 via simplytest.me

Tested:
Go to /admin/people/permissions
Scroll down the page

Confirmed > no more raw HTML tags visible
(Issue Review and test part of #Drupal8nz)

I am not sure if this needs further review before it can go RTBC so I leave it as needs review :). Ta!

heiket’s picture

Assigned: heiket » Unassigned

And screenshot after patch was applied

dawehner’s picture

Status: Needs review » Reviewed & tested by the community
+++ b/core/modules/user/src/Form/UserPermissionsForm.php
@@ -140,18 +140,16 @@ public function buildForm(array $form, FormStateInterface $form_state) {
         $form['permissions'][$perm]['description'] = array(
-          '#wrapper_attributes' => array(
-            'class' => array('permission'),
...
+          '#template' => '<div class="permission"><span class="title">{{ title }}</span><div class="description">{% if item_warning %}<em class="permission-warning"> {{ item_warning }}</em> {% endif %}{{ user_permission_description }}</div></div>',

It is much better to have an explicit div than a wrapper_attribute thing.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

Can we have a screenshot in non compact mode - ie have the descriptions on the permissions page.

+++ b/core/modules/user/src/Form/UserPermissionsForm.php
@@ -140,18 +140,16 @@ public function buildForm(array $form, FormStateInterface $form_state) {
         if (!$hide_descriptions) {
           $user_permission_description = $perm_item['description'];
-          // Append warning message.
-          if (!empty($perm_item['warning'])) {
-            $user_permission_description .= ' <em class="permission-warning">' . $perm_item['warning'] . '</em>';
-          }
...
+            'user_permission_description' => $user_permission_description,
+            'item_warning' => $perm_item['warning'],

This looks dangerous code and the logic has changed the warning will be displayed regardless of whether the descriptions are hidden. Perhaps we could just swap the order of everything around. For example:

        $form['permissions'][$perm]['description'] = array(
          '#type' => 'inline_template',
          '#template' => '<div class="permission"><span class="title">{{ title }}</span>{% if description or warning %}<div class="description">{% if warning %}<em class="permission-warning"> {{ warning }}</em> {% endif %}{{ description }}</div>{% endif %}</div>',
          '#context' => array(
            'title' => $perm_item['title'],
          ),
        );
        // Show the permission description.
        if (!$hide_descriptions) {
          $form['permissions'][$perm]['description']['#context']['description'] = $perm_item['description'];
          $form['permissions'][$perm]['description']['#context']['warning'] = $perm_item['warning'];
        }
haza’s picture

Status: Needs work » Needs review
StatusFileSize
new2.04 KB
new22.11 KB

You were right, thanks alexpott.
Changed the logic of the patch as mentionned.

Screenshot with hidden description :

alexpott’s picture

@Haza nice work! How about a screenshot with descriptions?

haza’s picture

StatusFileSize
new50.47 KB

Whoops, forgot that :)
Here it is :

akalata’s picture

Status: Needs review » Reviewed & tested by the community

Looks good!

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 9ff1ef3 and pushed to 8.0.x. Thanks!

  • alexpott committed 9ff1ef3 on 8.0.x
    Issue #2322465 by Haza | roald.umandal: Fixed HTML tag is visible in...

Status: Fixed » Closed (fixed)

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

jibran’s picture

Issue tags: +SafeMarkup