diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-01 15:30:02 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-01 15:30:02 -0400 |
commit | 1de335ad3f395ca6861085393ba366a9e3fb4a0d (patch) | |
tree | f1fdd326034e05177596851be6a7127615d81498 /includes/media/DjVuImage.php | |
parent | 9c75fa8ff6d4d38ef552c00fef5969fb154765e8 (diff) | |
parent | f6d65e533c62f6deb21342d4901ece24497b433e (diff) |
Merge commit 'f6d65'
# Conflicts:
# skins/ArchLinux/ArchLinux.php
Diffstat (limited to 'includes/media/DjVuImage.php')
-rw-r--r-- | includes/media/DjVuImage.php | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/includes/media/DjVuImage.php b/includes/media/DjVuImage.php index 6ff19c90..e8faa70a 100644 --- a/includes/media/DjVuImage.php +++ b/includes/media/DjVuImage.php @@ -265,37 +265,34 @@ class DjVuImage { /** * Return an XML string describing the DjVu image - * @return string + * @return string|bool */ function retrieveMetaData() { global $wgDjvuToXML, $wgDjvuDump, $wgDjvuTxt; - wfProfileIn( __METHOD__ ); + + if ( !$this->isValid() ) { + return false; + } if ( isset( $wgDjvuDump ) ) { # djvudump is faster as of version 3.5 # http://sourceforge.net/tracker/index.php?func=detail&aid=1704049&group_id=32953&atid=406583 - wfProfileIn( 'djvudump' ); $cmd = wfEscapeShellArg( $wgDjvuDump ) . ' ' . wfEscapeShellArg( $this->mFilename ); $dump = wfShellExec( $cmd ); $xml = $this->convertDumpToXML( $dump ); - wfProfileOut( 'djvudump' ); } elseif ( isset( $wgDjvuToXML ) ) { - wfProfileIn( 'djvutoxml' ); $cmd = wfEscapeShellArg( $wgDjvuToXML ) . ' --without-anno --without-text ' . wfEscapeShellArg( $this->mFilename ); $xml = wfShellExec( $cmd ); - wfProfileOut( 'djvutoxml' ); } else { $xml = null; } # Text layer if ( isset( $wgDjvuTxt ) ) { - wfProfileIn( 'djvutxt' ); $cmd = wfEscapeShellArg( $wgDjvuTxt ) . ' --detail=page ' . wfEscapeShellArg( $this->mFilename ); wfDebug( __METHOD__ . ": $cmd\n" ); $retval = ''; $txt = wfShellExec( $cmd, $retval, array(), array( 'memory' => self::DJVUTXT_MEMORY_LIMIT ) ); - wfProfileOut( 'djvutxt' ); if ( $retval == 0 ) { # Strip some control characters $txt = preg_replace( "/[\013\035\037]/", "", $txt ); @@ -316,14 +313,13 @@ EOR; $xml = $xml . $txt . '</mw-djvu>'; } } - wfProfileOut( __METHOD__ ); return $xml; } function pageTextCallback( $matches ) { # Get rid of invalid UTF-8, strip control characters - $val = htmlspecialchars( UtfNormal::cleanUp( stripcslashes( $matches[1] ) ) ); + $val = htmlspecialchars( UtfNormal\Validator::cleanUp( stripcslashes( $matches[1] ) ) ); $val = str_replace( array( "\n", '�' ), array( ' ', '' ), $val ); return '<PAGE value="' . $val . '" />'; } |