X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FDjVuImage.php;h=75df0fd59f09ebbccf331e9cf24f0101dbed8d09;hb=819ffd2be340513bfe40be368fe4699af639977b;hp=406878d076ba1e085fd3f580cae2af13492aaa5c;hpb=29729e7f5757147f06e6db53abd72ee327f05809;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/DjVuImage.php b/includes/DjVuImage.php index 406878d076..75df0fd59f 100644 --- a/includes/DjVuImage.php +++ b/includes/DjVuImage.php @@ -250,6 +250,15 @@ class DjVuImage { $txt = wfShellExec( $cmd, $retval ); wfProfileOut( 'djvutxt' ); if( $retval == 0) { + # Get rid of invalid UTF-8, strip control characters + if( is_callable( 'iconv' ) ) { + wfSuppressWarnings(); + $txt = iconv( "UTF-8","UTF-8//IGNORE", $txt ); + wfRestoreWarnings(); + } else { + $txt = UtfNormal::cleanUp( $txt ); + } + $txt = preg_replace( "/[\013\035\037]/", "", $txt ); $txt = htmlspecialchars($txt); $txt = preg_replace( "/\((page\s[\d-]*\s[\d-]*\s[\d-]*\s[\d-]*\s*\"([^<]*?)\"\s*|)\)/s", "", $txt ); $txt = "\n\n\n" . $txt . "\n\n";