Escape the header title & section title in reports.
authoreileen <emcnaughton@wikimedia.org>
Tue, 15 Jan 2019 02:43:34 +0000 (15:43 +1300)
committereileen <emcnaughton@wikimedia.org>
Tue, 15 Jan 2019 02:43:34 +0000 (15:43 +1300)
In extended reports I'm making it possible for column titles to be user edited. since they will represent user input it
makes sense to escape on output. I think core makes sense as the place to do this as it is best practice
to escape all output in the smarty layer and I have tested that it still works fine

templates/CRM/Report/Form/Layout/Table.tpl

index e7f24d6b84c95d0098e97f19f856003b2ffe6c14..76c0ca053c696d0101e085d371f695a9c08f33cd 100644 (file)
                 {/if}
                 {if !$skip}
                    {if $header.colspan}
-                       <th colspan={$header.colspan}>{$header.title}</th>
+                       <th colspan={$header.colspan}>{$header.title|escape}</th>
                       {assign var=skip value=true}
                       {assign var=skipCount value=`$header.colspan`}
                       {assign var=skipMade  value=1}
                    {else}
-                       <th {$class}>{$header.title}</th>
+                       <th {$class}>{$header.title|escape}</th>
                    {assign var=skip value=false}
                    {/if}
                 {else} {* for skip case *}
@@ -93,7 +93,7 @@
                     {$l}/if{$r}
                     <tr class="crm-report-sectionHeader crm-report-sectionHeader-{$h}"><th colspan="{$columnCount}">
 
-                        <h{$h}>{$section.title}: {$l}$printValue|default:"<em>none</em>"{$r}
+                        <h{$h}>{$section.title|escape}: {$l}$printValue|default:"<em>none</em>"{$r}
                             ({$l}sectionTotal key=$row.{$column} depth={$smarty.foreach.sections.index}{$r})
                         </h{$h}>
                     </th></tr>