Commits

David Matthewman committed 956fadc

The title of each item in the RSS feed was being double-encoded,
and also contained HTML, which it shouldn't have. The text is now
decoded before being passed to the RSS code, and <i> and <b>
tags stripped.

Change-Id: I3493b702eaf01933528f97477a7ed8c26c3c9075

Comments (0)

Files changed (2)

loader/alldivisions2rss.pl

 use PublicWhip::Parliaments;
 use PublicWhip::SQLfragments;
 use XML::RSS;
+use HTML::Entities;
 
 my $dbh = PublicWhip::DB::connect();
 my $this_parliament=PublicWhip::Parliaments::getcurrent();
    },
  );
 
-   while (my $result= $results->fetchrow_hashref) {
-            $rss->add_item(
-	          title => "Division: $result->{division_name}",
-                  link => "http://www.publicwhip.org.uk/division.php?date=$result->{division_date}&number=$result->{division_number}&house=$result->{house}",
-		  description=> "Vote on $result->{division_name} on $result->{division_date} ($result->{rebellions} rebellions; $result->{turnout} voters)"
-                );
+while (my $result= $results->fetchrow_hashref) {
+    my $division_name = decode_entities($result->{'division_name'});
+    $division_name =~ s{< /? i >}{_}xmsg;
+    $division_name =~ s{< /? b >}{*}xmsg;
+    $rss->add_item(
+        title       => "Division: $division_name",
+        link        => "http://www.publicwhip.org.uk/division.php?date=$result->{division_date}&number=$result->{division_number}&house=$result->{house}",
+        description => "Vote on $result->{division_name} on $result->{division_date} ($result->{rebellions} rebellions; $result->{turnout} voters)"
+    );
 
 }
    print $rss->as_string;

loader/interestingdivisions2rss.pl

 use PublicWhip::Parliaments;
 use PublicWhip::SQLfragments;
 use XML::RSS;
+use HTML::Entities;
 
 my $dbh = PublicWhip::DB::connect();
 my $this_parliament=PublicWhip::Parliaments::getcurrent();
    },
  );
 
-   while (my $result= $results->fetchrow_hashref) {
-            $rss->add_item(
-	          title => "$result->{rebellions} Rebellions in $result->{division_name}",
-                  link => "http://www.publicwhip.org.uk/division.php?date=$result->{division_date}&number=$result->{division_number}&house=$result->{house}",
-		  description=> "$result->{rebellions} rebellions ($result->{turnout} voters) in vote on $result->{division_name} on $result->{division_date}"
-                );
+while (my $result= $results->fetchrow_hashref) {
+    my $division_name = decode_entities($result->{'division_name'});
+    $division_name =~ s{< /? i >}{_}xmsg;
+    $division_name =~ s{< /? b >}{*}xmsg;
+    $rss->add_item(
+	   title       => "$result->{rebellions} Rebellions in $division_name",
+       link        => "http://www.publicwhip.org.uk/division.php?date=$result->{division_date}&number=$result->{division_number}&house=$result->{house}",
+       description => "$result->{rebellions} rebellions ($result->{turnout} voters) in vote on $result->{division_name} on $result->{division_date}"
+    );
 
 }
    print $rss->as_string;