r13304 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r13303‎ | r13304 | r13305 >
Date:16:48, 24 March 2006
Author:gabrielwicke
Status:old
Tags:
Comment:
Don't place html in alt/title attributes, especially with thumbnails
Modified paths:
  • /trunk/phase3/includes/Parser.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Parser.php
@@ -3173,6 +3173,13 @@
31743174 $valid = '0123456789-Xx';
31753175
31763176 foreach ( $a as $x ) {
 3177+ # hack: don't replace inside thumbnail title/alt
 3178+ # attributes
 3179+ if(preg_match('/<[^>]+(alt|title)="[^">]*$/', $text)) {
 3180+ $text .= "ISBN $x";
 3181+ continue;
 3182+ }
 3183+
31773184 $isbn = $blank = '' ;
31783185 while ( ' ' == $x{0} ) {
31793186 $blank .= ' ';
@@ -3195,7 +3202,7 @@
31963203 } else {
31973204 $titleObj = Title::makeTitle( NS_SPECIAL, 'Booksources' );
31983205 $text .= '<a href="' .
3199 - $titleObj->escapeLocalUrl( 'isbn='.$num ) .
 3206+ $titleObj->escapeLocalUrl( 'isbn='.$num ) .
32003207 "\" class=\"internal\">ISBN $isbn</a>";
32013208 $text .= $x;
32023209 }
@@ -3239,6 +3246,13 @@
32403247 continue;
32413248 }
32423249
 3250+ # hack: don't replace inside thumbnail title/alt
 3251+ # attributes
 3252+ if(preg_match('/<[^>]+(alt|title)="[^">]*$/', $text)) {
 3253+ $text .= $keyword . $x;
 3254+ continue;
 3255+ }
 3256+
32433257 $id = $blank = '' ;
32443258
32453259 /** remove and save whitespaces in $blank */
@@ -3824,6 +3838,11 @@
38253839 }
38263840 # Strip bad stuff out of the alt text
38273841 $alt = $this->replaceLinkHoldersText( $caption );
 3842+
 3843+ # make sure there are no placeholders in thumbnail attributes
 3844+ # that are later expanded to html- so expand them now and
 3845+ # remove the tags
 3846+ $alt = $this->unstrip($alt, $this->mStripState);
38283847 $alt = Sanitizer::stripAllTags( $alt );
38293848
38303849 # Linker does the rest

Status & tagging log