Merge "Kill 'newmessageslink' and 'newmessagesdifflink' messages"
[lhc/web/wiklou.git] / maintenance / generateSitemap.php
index b356d18..ab28c8b 100644 (file)
@@ -26,7 +26,7 @@
  * @see http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd
  */
 
-require_once( __DIR__ . '/Maintenance.php' );
+require_once __DIR__ . '/Maintenance.php';
 
 /**
  * Maintenance script that generates a sitemap for the site.
@@ -125,7 +125,6 @@ class GenerateSitemap extends Maintenance {
         */
        public $findex;
 
-
        /**
         * A resource pointing to a sitemap file
         *
@@ -378,7 +377,7 @@ class GenerateSitemap extends Maintenance {
        function open( $file, $flags ) {
                $resource = $this->compress ? gzopen( $file, $flags ) : fopen( $file, $flags );
                if ( $resource === false ) {
-                       wfDebugDieBacktrace( __METHOD__ . " error opening file $file with flags $flags. Check permissions?" );
+                       throw new MWException( __METHOD__ . " error opening file $file with flags $flags. Check permissions?" );
                }
                return $resource;
        }
@@ -388,7 +387,7 @@ class GenerateSitemap extends Maintenance {
         */
        function write( &$handle, $str ) {
                if ( $handle === true || $handle === false ) {
-                       wfDebugDieBacktrace( __METHOD__ . " was passed a boolean as a file handle.\n" );
+                       throw new MWException( __METHOD__ . " was passed a boolean as a file handle.\n" );
                }
                if ( $this->compress ) {
                        gzwrite( $handle, $str );
@@ -490,7 +489,8 @@ class GenerateSitemap extends Maintenance {
        function fileEntry( $url, $date, $priority ) {
                return
                        "\t<url>\n" .
-                       "\t\t<loc>$url</loc>\n" .
+                       // bug 34666: $url may contain bad characters such as ampersands.
+                       "\t\t<loc>" . htmlspecialchars( $url ) . "</loc>\n" .
                        "\t\t<lastmod>$date</lastmod>\n" .
                        "\t\t<priority>$priority</priority>\n" .
                        "\t</url>\n";
@@ -521,4 +521,4 @@ class GenerateSitemap extends Maintenance {
 }
 
 $maintClass = "GenerateSitemap";
-require_once( RUN_MAINTENANCE_IF_MAIN );
+require_once RUN_MAINTENANCE_IF_MAIN;