create-package-feed.pl: Add some new lines in output file
[privoxy.git] / utils / create-package-feed.pl
index 6e87588..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,19 +82,19 @@ 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) =
                 gmtime($target_time);
-            $target_line .=
-                  "$days[$wday], $mday $months[$mon] "
-                . ($year + 1900)
-                . " $hour:$min:$sec GMT";
+            $target_line .= sprintf("%s, %s %s %d %.2d:%.2d:%.2d GMT",
+                $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]);
@@ -110,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;
@@ -125,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";