* Move escaping of image gallery captions to ImageGallery::setCaption()
authorRob Church <robchurch@users.mediawiki.org>
Thu, 4 Jan 2007 19:47:11 +0000 (19:47 +0000)
committerRob Church <robchurch@users.mediawiki.org>
Thu, 4 Jan 2007 19:47:11 +0000 (19:47 +0000)
* Allow developers to set HTML gallery captions with ImageGallery::setCaptionSafe()
* (bug 8489) Support basic links in <gallery> caption attribute

RELEASE-NOTES
includes/ImageGallery.php
includes/Parser.php

index 2c4f3bf..66a0095 100644 (file)
@@ -461,6 +461,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   $wgDisableQueryPageUpdate
 * (bug 8413) Improve comments for $wgNamespaceRobotPolicies
 * (bug 8330) Show "bytes" suffix on recent changes diff counter
+* (bug 8489) Support basic links in <gallery> caption attribute
 
 == Languages updated ==
 
index e88ab8b..4fde005 100644 (file)
@@ -42,11 +42,20 @@ class ImageGallery
        }
        
        /**
-        * Set the caption
+        * Set the caption (as plain text)
         *
         * @param $caption Caption
         */
        function setCaption( $caption ) {
+               $this->mCaption = htmlspecialchars( $caption );
+       }
+       
+       /**
+        * Set the caption (as HTML)
+        *
+        * @param $caption Caption
+        */
+       function setCaptionSafe( $caption ) {
                $this->mCaption = $caption;
        }
 
@@ -140,7 +149,7 @@ class ImageGallery
 
                $s = '<table class="gallery" cellspacing="0" cellpadding="0">';
                if( $this->mCaption )
-                       $s .= '<td class="galleryheader" colspan="4"><big>' . htmlspecialchars( $this->mCaption ) . '</big></td>';
+                       $s .= '<td class="galleryheader" colspan="4"><big>' . $this->mCaption . '</big></td>';
                
                $i = 0;
                foreach ( $this->mImages as $pair ) {
index 258f6c3..7b480eb 100644 (file)
@@ -4300,8 +4300,12 @@ class Parser
                $ig->setParsing();
                $ig->useSkin( $this->mOptions->getSkin() );
 
-               if( isset( $params['caption'] ) )
-                       $ig->setCaption( $params['caption'] );
+               if( isset( $params['caption'] ) ) {
+                       $caption = $params['caption'];
+                       $caption = htmlspecialchars( $caption );
+                       $caption = $this->replaceInternalLinks( $caption );
+                       $ig->setCaptionSafe( $caption );
+               }
 
                $lines = explode( "\n", $text );
                foreach ( $lines as $line ) {