From d8fa790eb2115207f19ac011eb92d755bce764e3 Mon Sep 17 00:00:00 2001 From: ThomasV Date: Thu, 3 Sep 2009 14:19:24 +0000 Subject: [PATCH] get rid of invalid UTF8, strip control characters --- includes/DjVuImage.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/includes/DjVuImage.php b/includes/DjVuImage.php index 406878d076..c49971e1c4 100644 --- a/includes/DjVuImage.php +++ b/includes/DjVuImage.php @@ -250,6 +250,9 @@ class DjVuImage { $txt = wfShellExec( $cmd, $retval ); wfProfileOut( 'djvutxt' ); if( $retval == 0) { + # Get rid of invalid UTF-8, strip control characters + $txt = iconv( "UTF-8","UTF-8//IGNORE", $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"; -- 2.20.1