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