Index: branches/wmf/1.16wmf4/includes/DjVuImage.php |
— | — | @@ -259,8 +259,18 @@ |
260 | 260 | $txt = UtfNormal::cleanUp( $txt ); |
261 | 261 | } |
262 | 262 | $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*\"([^<]*?)\"\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 ); |
265 | 275 | $txt = "<DjVuTxt>\n<HEAD></HEAD>\n<BODY>\n" . $txt . "</BODY>\n</DjVuTxt>\n"; |
266 | 276 | $xml = preg_replace( "/<DjVuXML>/", "<mw-djvu><DjVuXML>", $xml ); |
267 | 277 | $xml = $xml . $txt. '</mw-djvu>' ; |
— | — | @@ -269,6 +279,10 @@ |
270 | 280 | return $xml; |
271 | 281 | } |
272 | 282 | |
| 283 | + function pageTextCallback( $matches ) { |
| 284 | + return '<PAGE value="' . htmlspecialchars( $matches[1] ) . '" />'; |
| 285 | + } |
| 286 | + |
273 | 287 | /** |
274 | 288 | * Hack to temporarily work around djvutoxml bug |
275 | 289 | */ |
Property changes on: branches/wmf/1.16wmf4/includes/DjVuImage.php |
___________________________________________________________________ |
Added: svn:mergeinfo |
276 | 290 | Merged /branches/wmf-deployment/includes/DjVuImage.php:r53381,60970 |
277 | 291 | Merged /branches/REL1_15/phase3/includes/DjVuImage.php:r51646 |
278 | 292 | Merged /branches/sqlite/includes/DjVuImage.php:r58211-58321 |
279 | 293 | 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 |