A simple Makefile to easily generate tar balls for distribution
[matthijs/upstream/blosxom.git] / blosxom.cgi
index 3d7727a9c3448bf45be0cc24387d71c39ce06f07..3ebe972c88108cbcb1746d2fc513da371bc63565 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 
 # Blosxom
-# Author: Rael Dornfest <rael@oreilly.com>
+# Author: Rael Dornfest (2003), The Blosxom Development Team (2005-2008)
 # Version: 2.1.0
 # Home/Docs/Licensing: http://blosxom.sourceforge.net/
 # Development/Downloads: http://sourceforge.net/projects/blosxom
@@ -661,17 +661,30 @@ sub generate {
             }
 
             if ( $encode_xml_entities && $content_type =~ m{\bxml\b} ) {
+                # Escape special characters inside the <link> container
+
+                # The following line should be moved more towards to top for
+                # performance reasons -- Axel Beckert, 2008-07-22
+                my $url_escape_re = qr([^-/a-zA-Z0-9:._]);
+
+                $url   =~ s($url_escape_re)(sprintf('%%%02X', ord($&)))eg;
+                $path  =~ s($url_escape_re)(sprintf('%%%02X', ord($&)))eg;
+                $fn    =~ s($url_escape_re)(sprintf('%%%02X', ord($&)))eg;
 
                 # Escape <, >, and &, and to produce valid RSS
                 my %escape = (
                     '<' => '&lt;',
                     '>' => '&gt;',
                     '&' => '&amp;',
-                    '"' => '&quot;'
+                    '"' => '&quot;',
+                    "'" => '&apos;'
                 );
                 my $escape_re = join '|' => keys %escape;
                 $title =~ s/($escape_re)/$escape{$1}/g;
                 $body  =~ s/($escape_re)/$escape{$1}/g;
+                $url   =~ s/($escape_re)/$escape{$1}/g;
+                $path  =~ s/($escape_re)/$escape{$1}/g;
+                $fn    =~ s/($escape_re)/$escape{$1}/g;
             }
 
             $story = &$interpolate($story);
@@ -780,7 +793,7 @@ rss story     <title>$title</title>
 rss story     <pubDate>$dw, $da $mo $yr $ti:00 $utc_offset</pubDate>
 rss story     <link>$url/$yr/$mo_num/$da#$fn</link>
 rss story     <category>$path</category>
-rss story     <guid isPermaLink="false">$path/$fn</guid>
+rss story     <guid isPermaLink="true">$url$path/$fn</guid>
 rss story     <description>$body</description>
 rss story   </item>