r73703 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r73702‎ | r73703 | r73704 >
Date:02:19, 25 September 2010
Author:kwisatz
Status:deferred
Tags:
Comment:
QrCode replaced the comment being added to the image upload by a non-stripped string
Modified paths:
  • /trunk/extensions/QrCode/QrCode.php (modified) (history)

Diff [purge]

Index: trunk/extensions/QrCode/QrCode.php
@@ -85,8 +85,9 @@
8686
8787 private $_parser; // simply a link to the parser object
8888 private $_title; // the current page's title object
 89+ private $_label; // contents of the qrcode
8990 private $_dstFileName; // what the file will be named?
90 - private $_label; // What will the qrcode contain?
 91+ private $_uploadComment; // comment to be added to the upload
9192 private $_ecc; // error correction
9293 private $_size; // qrcode size
9394 private $_margin; // qrcode margin
@@ -113,8 +114,10 @@
114115 // Also strip all non-alphanumeric characters
115116 if ( $label ) {
116117 $this->_label = preg_replace("/[^0-9a-zA-Z_]+/", "", $label);
 118+ $this->_uploadComment = $label; // should we sanitize this?
117119 } else {
118120 $this->_label = $this->_title->getFullURL();
 121+ $this->_uploadComment = 'Encoded URL for '.$this->_title->getFullText();
119122 }
120123
121124 // Use this page's title as part of the filename (Also regenerates qrcodes when the label changes).
@@ -183,16 +186,18 @@
184187 $ft = Title::makeTitleSafe( NS_FILE, $this->_dstFileName );
185188 $localfile = wfLocalFile( $ft ); // Get an object referring to a locally registered file.
186189 $saveName = $localfile->getName();
 190+
187191 $pageText = 'QrCode '.$saveName.', generated on '.date( "r" )
188192 .' by the QrCode Extension for page '.$this->_title->getFullText().'.';
189 - $status = $localfile->upload( $tmpName, $this->_label, $pageText, File::DELETE_SOURCE, false, false, $this->_getBot() );
190193
 194+ $status = $localfile->upload( $tmpName, $this->_uploadComment, $pageText,
 195+ File::DELETE_SOURCE, false, false, $this->_getBot() );
 196+
191197 if( !$status->isGood() ){
192198 $wgOut->addWikiText( $status->getWikiText() );
193199 return false;
194200 } else {
195 - // now that we generated the file, let's display it
196 - return $this->_displayImage( $ft );
 201+ return $this->_displayImage( $ft ); // display the generated file
197202 }
198203 }
199204

Status & tagging log