r69139 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r69138‎ | r69139 | r69140 >
Date:11:05, 7 July 2010
Author:thomasv
Status:resolved
Tags:
Comment:
fix text layer extraction (bug 21526); patch by Simon Lipp
Modified paths:
  • /trunk/phase3/includes/DjVuImage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/DjVuImage.php
@@ -259,8 +259,21 @@
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,
 275+ create_function('$matches', 'return \'<PAGE value="\'.htmlspecialchars($matches[1]).\'" />\';'),
 276+ $txt );
 277+
265278 $txt = "<DjVuTxt>\n<HEAD></HEAD>\n<BODY>\n" . $txt . "</BODY>\n</DjVuTxt>\n";
266279 $xml = preg_replace( "/<DjVuXML>/", "<mw-djvu><DjVuXML>", $xml );
267280 $xml = $xml . $txt. '</mw-djvu>' ;

Follow-up revisions

RevisionCommit summaryAuthorDate
r78046Fix for r69139: create_function() is not allowed.tstarling05:57, 8 December 2010
r78047MFT r69139, r78046: replace djvutxt output parsing regex with a slightly less...tstarling06:01, 8 December 2010

Status & tagging log