From: Rob Church Date: Thu, 4 Jan 2007 19:47:11 +0000 (+0000) Subject: * Move escaping of image gallery captions to ImageGallery::setCaption() X-Git-Tag: 1.31.0-rc.0~54664 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/modifier.php?a=commitdiff_plain;h=a411a4e6f54a3b6c62d712f9d7a70ce2167420cc;p=lhc%2Fweb%2Fwiklou.git * Move escaping of image gallery captions to ImageGallery::setCaption() * Allow developers to set HTML gallery captions with ImageGallery::setCaptionSafe() * (bug 8489) Support basic links in caption attribute --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 2c4f3bf836..66a0095f9e 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 caption attribute == Languages updated == diff --git a/includes/ImageGallery.php b/includes/ImageGallery.php index e88ab8be99..4fde005a39 100644 --- a/includes/ImageGallery.php +++ b/includes/ImageGallery.php @@ -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 = ''; if( $this->mCaption ) - $s .= ''; + $s .= ''; $i = 0; foreach ( $this->mImages as $pair ) { diff --git a/includes/Parser.php b/includes/Parser.php index 258f6c390a..7b480eb56a 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -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 ) {