Skip to content

Commit

Permalink
Update cards to check body field against 'filtered_text' format
Browse files Browse the repository at this point in the history
This is to correct html entities not coming through properly encoded
  • Loading branch information
occupant committed Sep 29, 2022
1 parent ef9bd38 commit 33c0cbe
Show file tree
Hide file tree
Showing 13 changed files with 19 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@
{% if not node.isPublished() %}
<div class="unpublished">Unpublished</div>
{% endif %}
<p{{text_attributes.addClass(text_classes)}}>{{ tagless_body|striptags }}</p>
<p{{text_attributes.addClass(text_classes)}}>{{ tagless_body|striptags|check_markup('filtered_text') }}</p>
<p{{ secondlinkwrapper_attributes.addClass(second_link_wrapper_classes) }}><a{{ secondlink_attributes.addClass(second_link_classes).setAttribute('target', link_target) }} href="{{ link_url }}" aria-label="Article details">{{ link_title }}</a></p>
</div>
</article>
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@
<div{{ meta_attributes.addClass(meta_classes) }}>
{{ node.createdtime|format_date('date_readable') }}</div>
<h3{{ title_attributes.addClass(title_classes) }}><a{{ link_attributes.addClass(link_classes).setAttribute('target', link_target) }} class="link-expand" href="{{ link_url }}" rel="bookmark">{{ label }}</a></h3>
<p{{text_attributes.addClass(text_classes)}}>{{ tagless_body|striptags }}</p>
<p{{text_attributes.addClass(text_classes)}}>{{ tagless_body|striptags|check_markup('filtered_text') }}</p>
</div>

<p{{ secondlinkwrapper_attributes.addClass(second_link_wrapper_classes) }}><a{{ secondlink_attributes.addClass(second_link_classes).setAttribute('target', link_target) }} href="{{ link_url }}" aria-label="Article details">{{ link_title }}</a></p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@
{% if not node.isPublished() %}
<div class="unpublished">Unpublished</div>
{% endif %}
<p{{text_attributes.addClass(text_classes)}}>{{ tagless_body|striptags }}</p>
<p{{text_attributes.addClass(text_classes)}}>{{ tagless_body|striptags|check_markup('filtered_text') }}</p>
<p{{ secondlinkwrapper_attributes.addClass(second_link_wrapper_classes) }}><a{{ secondlink_attributes.addClass(second_link_classes).setAttribute('target', link_target) }} href="{{ link_url }}" aria-label="Event details">{{ link_title }}</a></p>
</div>
</article>
2 changes: 1 addition & 1 deletion templates/content/node--ubc-event--card-vertical.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@
{% if not (node.field_event_date.isEmpty == true) and content.field_event_date is defined %}
<p{{ meta_attributes.addClass(meta_classes)}} >{{ eventdate }}</p>
{% endif %}
<p{{ text_attributes.addClass(text_classes)}} >{{ tagless_body|striptags }}</p>
<p{{ text_attributes.addClass(text_classes)}} >{{ tagless_body|striptags|check_markup('filtered_text') }}</p>
</div>
<p{{ secondlinkwrapper_attributes.addClass(second_link_wrapper_classes) }}><a{{ secondlink_attributes.addClass(second_link_classes).setAttribute('target', link_target) }} href="{{ link_url }}" aria-label="Event details">{{ link_title }}</a></p>
</article>
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
{% if not node.isPublished() %}
<div class="unpublished">Unpublished</div>
{% endif %}
<p{{ text_attributes.addClass(text_classes)}} >{{ tagless_body|striptags }}</p>
<p{{ text_attributes.addClass(text_classes)}} >{{ tagless_body|striptags|check_markup('filtered_text') }}</p>
<p{{ secondlinkwrapper_attributes.addClass(second_link_wrapper_classes) }}><a{{ secondlink_attributes.addClass(second_link_classes) }} href="{{ url }}" aria-label="Details">Details</a></p>
</div>
</article>
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
<div{{ meta_attributes.addClass(meta_classes) }}>
{{ node.createdtime|format_date('date_readable') }}</div>
<h3{{ title_attributes.addClass(title_classes) }}><a{{ link_attributes.addClass(link_classes) }} class="link-expand" href="{{ url }}" rel="bookmark">{{ label }}</a></h3>
<p{{ text_attributes.addClass(text_classes)}} >{{ tagless_body|striptags }}</p>
<p{{ text_attributes.addClass(text_classes)}} >{{ tagless_body|striptags|check_markup('filtered_text') }}</p>
</div>
<p{{ secondlinkwrapper_attributes.addClass(second_link_wrapper_classes) }}><a{{ secondlink_attributes.addClass(second_link_classes) }} href="{{ url }}" aria-label="Details">Details</a></p>
</article>
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@
</div>
{% if not (node.body.isEmpty == true) and content.body is defined %}
<div class="md--col-span-1 lg--col-span-2">
<p{{text_attributes.addClass(text_classes)}}>{{ tagless_body|striptags }}</p>
<p{{text_attributes.addClass(text_classes)}}>{{ tagless_body|striptags|check_markup('filtered_text') }}</p>
</div>
{% endif %}
<div class="mt-auto text-right md--col-span-2 lg--col-span-3">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@
</div>
{% if not (node.body.isEmpty == true) and content.body is defined %}
<div class="md--col-span-1 lg--col-span-2">
<p{{text_attributes.addClass(text_classes)}}>{{ tagless_body|striptags }}</p>
<p{{text_attributes.addClass(text_classes)}}>{{ tagless_body|striptags|check_markup('filtered_text') }}</p>
</div>
{% endif %}
<div class="mt-auto text-right md--col-span-2 lg--col-span-3">
Expand Down
7 changes: 7 additions & 0 deletions templates/content/node--ubc-profile--card-vertical.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@
'unit-button',
]
%}
{# need to put content into variable for striptags to work #}
{% set tagless_body %}
{{ content.body }}
{% endset %}

<article{{ attributes.addClass(classes) }} >
{% if not (node.field_profile_image.isEmpty == true) and content.field_profile_image is defined %}
Expand Down Expand Up @@ -194,6 +198,9 @@
{% if not (node.field_profile_preferred_website.isEmpty == true) and content.field_profile_preferred_website is defined %}
<p class="mt-0 text-sm"><svg aria-hidden="true" class="inline-block w-4 h-4 mr-5 text-ubc-blue "><use xlink:href="#icon-link-external"></use></svg> <a href="{{ content.field_profile_preferred_website[0]['#url'] }}" class="link-expand-break">Website</a></p>
{% endif %}
{% if not (node.body.isEmpty == true) and content.body is defined %}
<p{{text_attributes.addClass(text_classes)}}>{{ tagless_body|striptags|check_markup('filtered_text') }}</p>
{% endif %}
</div>

<p{{ secondlinkwrapper_attributes.addClass(second_link_wrapper_classes) }}><a{{ secondlink_attributes.addClass(second_link_classes) }} href="{{ url }}" aria-label="View profile">View profile</a></p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
{% if not node.isPublished() %}
<div class="unpublished">Unpublished</div>
{% endif %}
<p{{ text_attributes.addClass(text_classes)}} >{{ tagless_body|striptags }}</p>
<p{{ text_attributes.addClass(text_classes)}} >{{ tagless_body|striptags|check_markup('filtered_text') }}</p>
<p{{ secondlinkwrapper_attributes.addClass(second_link_wrapper_classes) }}><a{{ secondlink_attributes.addClass(second_link_classes) }} href="{{ url }}" aria-label="Details">Learn more</a></p>
</div>
</article>
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
<div{{ meta_attributes.addClass(meta_classes) }}>
{{ node.createdtime|format_date('date_readable') }}</div>
<h3{{ title_attributes.addClass(title_classes) }}><a{{ link_attributes.addClass(link_classes) }} class="link-expand" href="{{ url }}" rel="bookmark">{{ label }}</a></h3>
<p{{ text_attributes.addClass(text_classes)}} >{{ tagless_body|striptags }}</p>
<p{{ text_attributes.addClass(text_classes)}} >{{ tagless_body|striptags|check_markup('filtered_text') }}</p>
</div>
<p{{ secondlinkwrapper_attributes.addClass(second_link_wrapper_classes) }}><a{{ secondlink_attributes.addClass(second_link_classes) }} href="{{ url }}" aria-label="Details">Learn more</a></p>
</article>
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
{% if not node.isPublished() %}
<div class="unpublished">Unpublished</div>
{% endif %}
<p{{ text_attributes.addClass(text_classes)}} >{{ tagless_body|striptags }}</p>
<p{{ text_attributes.addClass(text_classes)}} >{{ tagless_body|striptags|check_markup('filtered_text') }}</p>
<p{{ secondlinkwrapper_attributes.addClass(second_link_wrapper_classes) }}><a{{ secondlink_attributes.addClass(second_link_classes) }} href="{{ url }}" aria-label="Details">Learn more</a></p>
</div>
</article>
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
<div{{ meta_attributes.addClass(meta_classes) }}>
{{ node.createdtime|format_date('date_readable') }}</div>
<h3{{ title_attributes.addClass(title_classes) }}><a{{ link_attributes.addClass(link_classes) }} class="link-expand" href="{{ url }}" rel="bookmark">{{ label }}</a></h3>
<p{{ text_attributes.addClass(text_classes)}} >{{ tagless_body|striptags }}</p>
<p{{ text_attributes.addClass(text_classes)}} >{{ tagless_body|striptags|check_markup('filtered_text') }}</p>
</div>
<p{{ secondlinkwrapper_attributes.addClass(second_link_wrapper_classes) }}><a{{ secondlink_attributes.addClass(second_link_classes) }} href="{{ url }}" aria-label="Details">Learn more</a></p>
</article>

0 comments on commit 33c0cbe

Please sign in to comment.