Permalink
Browse files

include title in ->as_xml. Also encode feed_uri and title

  • Loading branch information...
1 parent 19239fc commit b8681298655c83cb091a1302120b04c1afaadee3 @miyagawa committed Mar 23, 2010
Showing with 11 additions and 1 deletion.
  1. +11 −1 lib/AnyEvent/Superfeedr/Notification.pm
@@ -57,11 +57,13 @@ sub as_atom_feed {
sub as_xml {
my $notification = shift;
my $id = $notification->tagify;
- my $feed_uri = $notification->feed_uri;
+ my $feed_uri = _xml_encode($notification->feed_uri);
+ my $title = _xml_encode($notification->title);
my $feed = <<EOX;
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<id>$id</id>
+<title>$title</title>
<link href="$feed_uri" rel="self" />
EOX
for my $node_entry ($notification->node_entries) {
@@ -71,6 +73,14 @@ EOX
return $feed;
}
+my %enc = ('&' => '&amp;', '"' => '&quot;', '<' => '&lt;', '>' => '&gt;', '\'' => '&#39;');
+
+sub _xml_encode {
+ local $_ = shift;
+ s/([&"\'<>])/$enc{$1}/g;
+ $_;
+}
+
sub tagify {
my $notification = shift;

0 comments on commit b868129

Please sign in to comment.