From b74cc5481080b832a10406bae85d55a6e4f7f40b Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 30 Sep 2008 00:21:59 +0000 Subject: [PATCH] Revert r41364 -- broke 22 parser test cases with change of alt behavior. The caption was originally defined *as* the alt text (defaulting to the image file name if there is no alt text). Note that a separate caption text is only displayed in some display modes ('frame' and 'thumb', iirc), and not by default. Please run the parser tests and check the effect you have on them. If it's really an appropriate change, then update the test cases. If you're not sure, consider backing out pending further discussion. :) It might be appropriate to not set the 'alt' attribute for frame/thumb cases, but definitely not for inline images where we already have a way of setting the alt text which you're removing! --- RELEASE-NOTES | 2 -- includes/parser/Parser.php | 42 ++++++++++++++++++++----------- languages/messages/MessagesEn.php | 1 - 3 files changed, 28 insertions(+), 17 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 78b85360b2..bd66b48ccf 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -140,8 +140,6 @@ The following extensions are migrated into MediaWiki 1.14: restriction types on the protection form. * (bug 8440) Allow preventing blocked users from editing their talk pages * Improved upload file type detection for OpenDocument formats -* (bug 368) Don't use caption for alt attribute; allow manual specification - using new "alt=" parameter for images === Bug fixes in 1.14 === diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 99463d2f35..a8556eb24b 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -4164,7 +4164,7 @@ class Parser 'vertAlign' => array( 'baseline', 'sub', 'super', 'top', 'text-top', 'middle', 'bottom', 'text-bottom' ), 'frame' => array( 'thumbnail', 'manualthumb', 'framed', 'frameless', - 'upright', 'border', 'alt' ), + 'upright', 'border' ), ); static $internalParamMap; if ( !$internalParamMap ) { @@ -4200,17 +4200,16 @@ class Parser function makeImage( $title, $options, $holders = false ) { # Check if the options text is of the form "options|alt text" # Options are: - # * thumbnail make a thumbnail with enlarge-icon and caption, alignment depends on lang - # * left no resizing, just left align. label is used for alt= only - # * right same, but right aligned - # * none same, but not aligned - # * ___px scale to ___ pixels width, no aligning. e.g. use in taxobox - # * center center the image - # * framed Keep original image size, no magnify-button. - # * frameless like 'thumb' but without a frame. Keeps user preferences for width - # * upright reduce width for upright images, rounded to full __0 px - # * border draw a 1px border around the image - # * alt Text for HTML alt attribute (defaults to empty) + # * thumbnail make a thumbnail with enlarge-icon and caption, alignment depends on lang + # * left no resizing, just left align. label is used for alt= only + # * right same, but right aligned + # * none same, but not aligned + # * ___px scale to ___ pixels width, no aligning. e.g. use in taxobox + # * center center the image + # * framed Keep original image size, no magnify-button. + # * frameless like 'thumb' but without a frame. Keeps user preferences for width + # * upright reduce width for upright images, rounded to full __0 px + # * border draw a 1px border around the image # vertical-align values (no % or length right now): # * baseline # * sub @@ -4279,8 +4278,7 @@ class Parser } else { # Validate internal parameters switch( $paramName ) { - case 'manualthumb': - case 'alt': + case "manualthumb": /// @fixme - possibly check validity here? /// downstream behavior seems odd with missing manual thumbs. $validated = true; @@ -4309,6 +4307,22 @@ class Parser $params['frame']['valign'] = key( $params['vertAlign'] ); } + # Strip bad stuff out of the alt text + # We can't just use replaceLinkHoldersText() here, because if this function + # is called from replaceInternalLinks2(), mLinkHolders won't be up to date. + if ( $holders ) { + $alt = $holders->replaceText( $caption ); + } else { + $alt = $this->replaceLinkHoldersText( $caption ); + } + + # make sure there are no placeholders in thumbnail attributes + # that are later expanded to html- so expand them now and + # remove the tags + $alt = $this->mStripState->unstripBoth( $alt ); + $alt = Sanitizer::stripAllTags( $alt ); + + $params['frame']['alt'] = $alt; $params['frame']['caption'] = $caption; wfRunHooks( 'ParserMakeImageParams', array( $title, $file, &$params ) ); diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 5f11681921..a6d1d4740e 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -287,7 +287,6 @@ $magicWords = array( 'img_middle' => array( 1, 'middle' ), 'img_bottom' => array( 1, 'bottom' ), 'img_text_bottom' => array( 1, 'text-bottom' ), - 'img_alt' => array( 1, 'alt=$1', 'alt $1' ), 'int' => array( 0, 'INT:' ), 'sitename' => array( 1, 'SITENAME' ), 'ns' => array( 0, 'NS:' ), -- 2.20.1