create-package-feed.pl: Add some new lines in output file
[privoxy.git] / utils / create-package-feed.pl
index ede1ee7..aff89ed 100644 (file)
@@ -66,6 +66,8 @@ while (my $fi1 = readdir($D1)) {
 
             # URI and Time
             $target_uri  = $fi1 . '/' . $fi2 . '/' . $fi3;
+            my $escaped_target_uri = $target_uri;
+            $escaped_target_uri =~ s@ @%20@g;
             $target_time = (stat $target)[9];
 
             # RSS line
@@ -80,10 +82,10 @@ while (my $fi1 = readdir($D1)) {
             $target_line .=
                   '<link>'
                 . $base_dlurl
-                . $target_uri
+                . $escaped_target_uri
                 . '</link><guid>'
                 . $base_dlurl
-                . $target_uri
+                . $escaped_target_uri
                 . '</guid>';
             $target_line .= '<pubDate>';
             ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
@@ -92,6 +94,7 @@ while (my $fi1 = readdir($D1)) {
                 $days[$wday], $mday, $months[$mon], ($year + 1900),
                 $hour, $min, $sec);
             $target_line .= '</pubDate></item>';
+            $target_line .= "\n";
 
             # Add it to Array
             $Array[$i] = ([$target_time, $target_line]);
@@ -109,13 +112,20 @@ closedir($D1);
 
 # Result = Full XML Codes
 my $result =
-    '<?xml version="1.0" encoding="utf-8"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" version="2.0"><channel><title>Privoxy Releases</title><link>https://www.privoxy.org/announce.txt</link><description><![CDATA[Privoxy Releases RSS feed]]></description><pubDate>';
+    '<?xml version="1.0" encoding="utf-8"?>
+ <rss xmlns:content="http://purl.org/rss/1.0/modules/content/" version="2.0">
+  <channel>
+   <title>Privoxy Releases</title>
+   <link>https://www.privoxy.org/announce.txt</link>
+   <description><![CDATA[Privoxy Releases RSS feed]]></description>
+   <pubDate>';
 ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = gmtime();
 $result .=
       "$days[$wday], $mday $months[$mon] "
     . ($year + 1900)
     . " $hour:$min:$sec GMT";
 $result .= '</pubDate>';
+$result .= "\n";
 
 # Sort Array
 my @resArray = sort { @$a[0] <=> @$b[0] } @Array;
@@ -124,7 +134,8 @@ while ($max_advertised_files-- > 0 && $i >= 0) {
     $result .= $resArray[$i][1];
     $i--;
 }
-$result .= '</channel></rss>';
+$result .= '  </channel>
+   </rss>';
 
 # Save it.
 open(my $XMLF, ">", $save_rss_file) or die "Failed to write XML file";