Revert r41364 -- broke 22 parser test cases with change of alt behavior.
authorBrion Vibber <brion@users.mediawiki.org>
Tue, 30 Sep 2008 00:21:59 +0000 (00:21 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Tue, 30 Sep 2008 00:21:59 +0000 (00:21 +0000)
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
includes/parser/Parser.php
languages/messages/MessagesEn.php

index 78b8536..bd66b48 100644 (file)
@@ -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 ===
index 99463d2..a8556eb 100644 (file)
@@ -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 ) );
index 5f11681..a6d1d47 100644 (file)
@@ -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:'                    ),