[Rt-commit] rt branch, 4.2/user-info-formatting, created. rt-4.1.6-318-g830a760

Thomas Sibley trs at bestpractical.com
Wed Mar 6 23:00:40 EST 2013


The branch, 4.2/user-info-formatting has been created
        at  830a7604906f720d9dc1ab9cd809a8529bf2d05e (commit)

- Log -----------------------------------------------------------------
commit 5effcaad34a93f3d3b27be6a471f54dab3f6c169
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Fri Mar 1 15:51:21 2013 -0800

    Revert "Switch from divs/spans to tables"
    
    This reverts commit cb3b5a57b1e887fa28e648a8d35b7a0c9b06c86f.
    
    Tables are annoying and hard to style well with CSS.  We lose
    flexibility going forward.  The underlying reason for the poor
    formatting noted in the reverted commit message is because the class
    name was mistakenly changed in the refactor and the relevant CSS no
    longer applied.  The class name will be fixed in the following commit,
    and all shall be well.

diff --git a/share/html/User/Elements/UserInfo b/share/html/User/Elements/UserInfo
index b5bd68b..c1322b8 100644
--- a/share/html/User/Elements/UserInfo
+++ b/share/html/User/Elements/UserInfo
@@ -45,7 +45,7 @@
 %# those contributions and any derivatives thereof.
 %#
 %# END BPS TAGGED BLOCK }}}
-<table class="<% $ClassPrefix %>-extra">
+<div class="<% $ClassPrefix %>-extra">
 % for my $column (@formats) {
 % my $title = $column->{title} || '';
 % my $attr = $column->{'attribute'} || $column->{'last_attribute'};
@@ -53,8 +53,8 @@
 %   $title = $fetch_columnmap->($attr,'title',[$attr]);
 % }
 % $title = $m->comp('/Elements/ScrubHTML', Content => $title);
-<tr class="<% $ClassPrefix %> extra-field <% $fetch_columnmap->($attr,'attribute',[$attr]) %>" >
-<td class="label"><% loc($title) %></td>
+<div class="<% $ClassPrefix %> extra-field <% $fetch_columnmap->($attr,'attribute',[$attr]) %>" >
+<span class="label"><% loc($title) %></span>
 % my @out;
 % foreach my $subcol ( @{ $column->{output} } ) {
 %     my ($col) = ($subcol =~ /^__(.*?)__$/);
@@ -65,10 +65,10 @@
 %     push @out, $fetch_columnmap->($col, 'value', [$User]);
 % }
 % @out = grep { defined $_ and length $_ } @out;
-<td class="value"><% join(' ', at out) %></td>
-</tr>
+<span class="value"><% join(' ', at out) %></span>
+</div>
 % }
-</table>
+</div>
 <%INIT>
 return unless $FormatConfig;
 my $format = RT->Config->Get($FormatConfig);

commit 211d663004a73eb2f52cee869dc290c233b724c8
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Fri Mar 1 15:53:45 2013 -0800

    Restore a crucial hyphen mistakenly dropped during the refactor in cb3b5a5
    
    Now the relevant CSS styles will apply again.

diff --git a/share/html/User/Elements/UserInfo b/share/html/User/Elements/UserInfo
index c1322b8..908739e 100644
--- a/share/html/User/Elements/UserInfo
+++ b/share/html/User/Elements/UserInfo
@@ -53,7 +53,7 @@
 %   $title = $fetch_columnmap->($attr,'title',[$attr]);
 % }
 % $title = $m->comp('/Elements/ScrubHTML', Content => $title);
-<div class="<% $ClassPrefix %> extra-field <% $fetch_columnmap->($attr,'attribute',[$attr]) %>" >
+<div class="<% $ClassPrefix %>-extra-field <% $fetch_columnmap->($attr,'attribute',[$attr]) %>" >
 <span class="label"><% loc($title) %></span>
 % my @out;
 % foreach my $subcol ( @{ $column->{output} } ) {

commit 64fda539d8852802d5e1e6abebb9f634caaba29f
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Fri Mar 1 15:55:49 2013 -0800

    Handle special characters in values used as CSS classes
    
    Class names from the column map may be "CF.{Foo}" otherwise, which is
    invalid and unaddressable using CSS selectors.

diff --git a/share/html/User/Elements/UserInfo b/share/html/User/Elements/UserInfo
index 908739e..75b39d1 100644
--- a/share/html/User/Elements/UserInfo
+++ b/share/html/User/Elements/UserInfo
@@ -53,7 +53,7 @@
 %   $title = $fetch_columnmap->($attr,'title',[$attr]);
 % }
 % $title = $m->comp('/Elements/ScrubHTML', Content => $title);
-<div class="<% $ClassPrefix %>-extra-field <% $fetch_columnmap->($attr,'attribute',[$attr]) %>" >
+<div class="<% $ClassPrefix %>-extra-field <% CSSClass($fetch_columnmap->($attr,'attribute',[$attr])) %>" >
 <span class="label"><% loc($title) %></span>
 % my @out;
 % foreach my $subcol ( @{ $column->{output} } ) {
@@ -84,6 +84,8 @@ my $fetch_columnmap = sub {
             );
     return ProcessColumnMapValue( $tmp, Arguments => $arguments, Escape => 0 );
 };
+
+$ClassPrefix = CSSClass($ClassPrefix) if $ClassPrefix;
 </%INIT>
 <%ARGS>
 $User => undef

commit 2752ef1a0b91d582f22a1f5f7baf3627d36f0c5e
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Fri Mar 1 16:20:08 2013 -0800

    Allow HTML in the $MoreAboutRequestorsExtraInfo format string
    
    This lets admins create links, use color, etc.  Since the format string
    is entirely RT server admin controlled, the HTML is not sanitized.  This
    allows greater flexibility for savvy admins.
    
    Keeping with good practice, $fetch_columnmap now escapes by default.
    The calls which fetch attributes instead of user record values turn off
    escaping explicitly.

diff --git a/share/html/User/Elements/UserInfo b/share/html/User/Elements/UserInfo
index 75b39d1..759e0bb 100644
--- a/share/html/User/Elements/UserInfo
+++ b/share/html/User/Elements/UserInfo
@@ -50,10 +50,10 @@
 % my $title = $column->{title} || '';
 % my $attr = $column->{'attribute'} || $column->{'last_attribute'};
 % unless (defined $column->{title}) {
-%   $title = $fetch_columnmap->($attr,'title',[$attr]);
+%   $title = $fetch_columnmap->($attr,'title',[$attr],'no_escape');
 % }
 % $title = $m->comp('/Elements/ScrubHTML', Content => $title);
-<div class="<% $ClassPrefix %>-extra-field <% CSSClass($fetch_columnmap->($attr,'attribute',[$attr])) %>" >
+<div class="<% $ClassPrefix %>-extra-field <% CSSClass($fetch_columnmap->($attr,'attribute',[$attr],'no_escape')) %>" >
 <span class="label"><% loc($title) %></span>
 % my @out;
 % foreach my $subcol ( @{ $column->{output} } ) {
@@ -65,7 +65,7 @@
 %     push @out, $fetch_columnmap->($col, 'value', [$User]);
 % }
 % @out = grep { defined $_ and length $_ } @out;
-<span class="value"><% join(' ', at out) %></span>
+<span class="value"><% join(' ', at out) |n %></span>
 </div>
 % }
 </div>
@@ -73,16 +73,19 @@
 return unless $FormatConfig;
 my $format = RT->Config->Get($FormatConfig);
 return unless $format;
+
+# Note that we don't need to ScrubHTML($format), because it's only modifiable
+# by the RT server admin.
 my @formats = $m->comp('/Elements/CollectionAsTable/ParseFormat', Format => $format);
 
 my $fetch_columnmap = sub {
-    my ($name, $attr, $arguments) = @_;
+    my ($name, $attr, $arguments, $no_escape) = @_;
     my $tmp = $m->comp( '/Elements/ColumnMap',
             Class => $Class,
             Name  => $name,
             Attr  => $attr,
             );
-    return ProcessColumnMapValue( $tmp, Arguments => $arguments, Escape => 0 );
+    return ProcessColumnMapValue( $tmp, Arguments => $arguments, Escape => !$no_escape );
 };
 
 $ClassPrefix = CSSClass($ClassPrefix) if $ClassPrefix;

commit 830a7604906f720d9dc1ab9cd809a8529bf2d05e
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Fri Mar 1 16:14:18 2013 -0800

    HTML escape any user field titles provided by the configured format
    
    This eases the use of &, <, >, etc in a format-supplied title (i.e via
    /TITLE:Foo).  In contrast, ColumnMap supplied titles are allowed to use
    HTML since they have another mechanism for proper escaping and expect to
    be able to output HTML.
    
    The title isn't scrubbed of disallowed HTML because it is only
    changeable by the RT server admin.  Before this commit, scrubbing the
    HTML was also moot since the Mason interpolation didn't turn off the
    default HTML escaping.

diff --git a/share/html/User/Elements/UserInfo b/share/html/User/Elements/UserInfo
index 759e0bb..cb1502c 100644
--- a/share/html/User/Elements/UserInfo
+++ b/share/html/User/Elements/UserInfo
@@ -47,14 +47,13 @@
 %# END BPS TAGGED BLOCK }}}
 <div class="<% $ClassPrefix %>-extra">
 % for my $column (@formats) {
-% my $title = $column->{title} || '';
+% my $title = $m->interp->apply_escapes($column->{title} || '', 'h');
 % my $attr = $column->{'attribute'} || $column->{'last_attribute'};
 % unless (defined $column->{title}) {
-%   $title = $fetch_columnmap->($attr,'title',[$attr],'no_escape');
+%   $title = $fetch_columnmap->($attr,'title',[$attr]);
 % }
-% $title = $m->comp('/Elements/ScrubHTML', Content => $title);
 <div class="<% $ClassPrefix %>-extra-field <% CSSClass($fetch_columnmap->($attr,'attribute',[$attr],'no_escape')) %>" >
-<span class="label"><% loc($title) %></span>
+<span class="label"><% loc($title) |n %></span>
 % my @out;
 % foreach my $subcol ( @{ $column->{output} } ) {
 %     my ($col) = ($subcol =~ /^__(.*?)__$/);

-----------------------------------------------------------------------


More information about the Rt-commit mailing list