From 8ac35e625a771cb16e936f5a74fa653fc1eb1f8f Mon Sep 17 00:00:00 2001 From: vfilippov Date: Mon, 19 Jan 2009 15:16:56 +0000 Subject: [PATCH] Bug 40933 more valid RSS git-svn-id: svn://svn.office.custis.ru/3rdparty/bugzilla.org/trunk@105 6955db30-a419-402b-8a0d-67ecbb4d7f56 --- Bugzilla/Template.pm | 8 ++++++++ rss-comments.cgi | 12 ++++++++---- t/004template.t | 1 + template/en/custom/list/comments.rss.tmpl | 11 ++++++----- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm index 4ef2a97ad..ade533498 100644 --- a/Bugzilla/Template.pm +++ b/Bugzilla/Template.pm @@ -704,6 +704,14 @@ sub create { return sub { wrap_comment($_[0], $cols) } }, 1], + absolute_uris => + sub { + my $b = Bugzilla->params->{urlbase}; + $b =~ s/\/*$/\//so; + $_[0] =~ s/(]*href\s*=\s*[\"\']\s*)(?![a-z]+:\/\/)([^\"\'<>]+[\"\'][^<>]*>)/$1$b$2/giso; + $_[0]; + }, + # We force filtering of every variable in key security-critical # places; we have a none filter for people to use when they # really, really don't want a variable to be changed. diff --git a/rss-comments.cgi b/rss-comments.cgi index f9b9b5c06..92367ee45 100755 --- a/rss-comments.cgi +++ b/rss-comments.cgi @@ -23,6 +23,7 @@ my $cgi = Bugzilla->cgi; my $template = Bugzilla->template; my $dbh = Bugzilla->dbh; +$vars->{selfurl} = $cgi->canonicalise_query(); $vars->{escapetags} = $cgi->param('escapetags'); $vars->{buginfo} = $cgi->param('buginfo'); @@ -71,7 +72,7 @@ my $bugsquery = " SELECT b.bug_id, b.short_desc, pr.name AS product, cm.name AS component, b.bug_severity, b.bug_status, - 0 AS work_time, '' AS thetext, '' AS commentlink, + 0 AS work_time, '' AS thetext, DATE_FORMAT(a.bug_when,'%Y%m%d%H%i%s') AS commentlink, DATE_FORMAT(a.bug_when,'%Y-%m-%dT%H:%iZ') bug_when, DATE_FORMAT(a.bug_when,'%a, %d %b %Y %H:%i:%s $tz') datetime_rfc822, a.bug_when AS `when`, p.login_name, p.realname, @@ -92,6 +93,7 @@ my $bugsquery = " $vars->{events} = $dbh->selectall_arrayref($bugsquery, {Slice => {}}); +my ($t, $o, $n); foreach (@{$vars->{events}}) { if ($_->{fieldname}) @@ -105,9 +107,11 @@ foreach (@{$vars->{events}}) $_->{old} = format_time_decimal($_->{old}); $_->{new} = format_time_decimal($_->{new}); } - my $t = "Changed '$_->{fielddesc}'"; - $t .= " from '$_->{old}'" if length $_->{old}; - $t .= " to '$_->{new}'" if length $_->{new}; + $o = 1 && length $_->{old}; + $n = 1 && length $_->{new}; + $t = "Changed '$_->{fielddesc}' from '$_->{old}' to '$_->{new}'" if $o && $n; + $t = "Added to '$_->{fielddesc}': '$_->{new}'" if !$o && $n; + $t = "Removed '$_->{fielddesc}': '$_->{old}'" if $o && !$n; $_->{thetext} = $t; } } diff --git a/t/004template.t b/t/004template.t index 31ce7927c..72e36b1b8 100644 --- a/t/004template.t +++ b/t/004template.t @@ -111,6 +111,7 @@ foreach my $include_path (@include_paths) { wrap_comment => sub { return $_ }, none => sub { return $_ } , ics => [ sub { return sub { return $_; } }, 1] , + absolute_uris => sub { return $_; } , }, } ); diff --git a/template/en/custom/list/comments.rss.tmpl b/template/en/custom/list/comments.rss.tmpl index e6fd2a222..8a5e164e7 100644 --- a/template/en/custom/list/comments.rss.tmpl +++ b/template/en/custom/list/comments.rss.tmpl @@ -3,18 +3,19 @@ [% USE date %] - + [% title FILTER xml %] [% Param('urlbase') %]buglist.cgi?[%- urlquerypart.replace('ctype=rss[&]?','') FILTER xml %] + [% "$terms.Bugzilla:" FILTER xml %][% title FILTER xml %] en [% builddate %] [% FOREACH evt = events %] [% evt.realname FILTER html %] [% IF evt.is_new > 0 %] added [% ELSE %] changed [% END %] bug [% evt.bug_id %]: [% evt.short_desc FILTER xml %] - [% Param('urlbase') FILTER xml %]show_bug.cgi?id=[% evt.bug_id FILTER xml %]#[%evt.commentlink%] - [% Param('urlbase') FILTER xml %]show_bug.cgi?id=[% evt.bug_id FILTER xml %]#[%evt.commentlink%] + [% Param('urlbase') FILTER xml %]show_bug.cgi?id=[% evt.bug_id FILTER xml %]#[% evt.commentlink %] + [% Param('urlbase') FILTER xml %]show_bug.cgi?id=[% evt.bug_id FILTER xml %]#[% evt.commentlink %] [% evt.datetime_rfc822 %] 0 %] @@ -26,7 +27,7 @@ [% END %]
-                    [% evt.thetext FILTER wrap_comment FILTER quoteUrls %]
+                    [% evt.thetext FILTER wrap_comment FILTER quoteUrls FILTER absolute_uris %]
                 
[% IF UserInGroup(Param('timetrackinggroup')) && (evt.work_time != 0 ) %]
[% evt.work_time %]
@@ -40,7 +41,7 @@ [% END %]
-                [% evt.thetext FILTER wrap_comment FILTER quoteUrls %]
+                [% evt.thetext FILTER wrap_comment FILTER quoteUrls FILTER absolute_uris %]
                 
[% IF UserInGroup(Param('timetrackinggroup')) && (evt.work_time != 0 ) %]
[% evt.work_time %]