r78047 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r78046‎ | r78047 | r78048 >
Date:06:01, 8 December 2010
Author:tstarling
Status:ok
Tags:
Comment:
MFT r69139, r78046: replace djvutxt output parsing regex with a slightly less sucky one.
Modified paths:
  • /branches/wmf/1.16wmf4/includes/DjVuImage.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.16wmf4/includes/DjVuImage.php
@@ -259,8 +259,18 @@
260260 $txt = UtfNormal::cleanUp( $txt );
261261 }
262262 $txt = preg_replace( "/[\013\035\037]/", "", $txt );
263 - $txt = htmlspecialchars($txt);
264 - $txt = preg_replace( "/\((page\s[\d-]*\s[\d-]*\s[\d-]*\s[\d-]*\s*\&quot;([^<]*?)\&quot;\s*|)\)/s", "<PAGE value=\"$2\" />", $txt );
 263+ $reg = <<<EOR
 264+ /\(page\s[\d-]*\s[\d-]*\s[\d-]*\s[\d-]*\s*"
 265+ ((?> # Text to match is composed of atoms of either:
 266+ \\\\. # - any escaped character
 267+ | # - any character different from " and \
 268+ [^"\\\\]+
 269+ )*?)
 270+ "\s*\)
 271+ | # Or page can be empty ; in this case, djvutxt dumps ()
 272+ \(\s*()\)/sx
 273+EOR;
 274+ $txt = preg_replace_callback( $reg, array( $this, 'pageTextCallback' ), $txt );
265275 $txt = "<DjVuTxt>\n<HEAD></HEAD>\n<BODY>\n" . $txt . "</BODY>\n</DjVuTxt>\n";
266276 $xml = preg_replace( "/<DjVuXML>/", "<mw-djvu><DjVuXML>", $xml );
267277 $xml = $xml . $txt. '</mw-djvu>' ;
@@ -269,6 +279,10 @@
270280 return $xml;
271281 }
272282
 283+ function pageTextCallback( $matches ) {
 284+ return '<PAGE value="' . htmlspecialchars( $matches[1] ) . '" />';
 285+ }
 286+
273287 /**
274288 * Hack to temporarily work around djvutoxml bug
275289 */
Property changes on: branches/wmf/1.16wmf4/includes/DjVuImage.php
___________________________________________________________________
Added: svn:mergeinfo
276290 Merged /branches/wmf-deployment/includes/DjVuImage.php:r53381,60970
277291 Merged /branches/REL1_15/phase3/includes/DjVuImage.php:r51646
278292 Merged /branches/sqlite/includes/DjVuImage.php:r58211-58321
279293 Merged /trunk/phase3/includes/DjVuImage.php:r63549,63764,63897-63901,64113,64509,65387,65391,65555,65590,65650,65816,69139,71059,71098,71942,72024,72120,72525,77555,77558-77560,77563-77565,77573,78046

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r69139fix text layer extraction (bug 21526); patch by Simon Lippthomasv11:05, 7 July 2010
r78046Fix for r69139: create_function() is not allowed.tstarling05:57, 8 December 2010

Status & tagging log