// This could possibly check to see if iconv is really installed
// or if we're using the compatibility wrapper in globalFunctions.php
if ($charset) {
+ wfSuppressWarnings();
$val = iconv($charset, 'UTF-8//IGNORE', $val);
+ wfRestoreWarnings();
} else {
// if valid utf-8, assume that, otherwise assume windows-1252
$valCopy = $val;
UtfNormal::quickIsNFCVerify( $valCopy ); //validates $valCopy.
if ( $valCopy !== $val ) {
+ wfSuppressWarnings();
$val = iconv('Windows-1252', 'UTF-8//IGNORE', $val);
+ wfRestoreWarnings();
}
}
*/
private static function convIPTCHelper ( $data, $charset ) {
if ( $charset ) {
+ wfSuppressWarnings();
$data = iconv($charset, "UTF-8//IGNORE", $data);
+ wfRestoreWarnings();
if ($data === false) {
$data = "";
wfDebugLog('iptc', __METHOD__ . " Error converting iptc data charset $charset to utf-8");
// First see if valid utf-8,
// if not try to convert it to windows-1252.
$com = $oldCom = trim( self::jpegExtractMarker( $fh ) );
-
UtfNormal::quickIsNFCVerify( $com );
// turns $com to valid utf-8.
// thus if no change, its utf-8, otherwise its something else.
if ( $com !== $oldCom ) {
- $oldCom = iconv( 'windows-1252', 'UTF-8//IGNORE', $oldCom );
+ wfSuppressWarnings();
+ $com = $oldCom = iconv( 'windows-1252', 'UTF-8//IGNORE', $oldCom );
+ wfRestoreWarnings();
+ }
+ // Try it again, if its still not a valid string, then probably
+ // binary junk or some really weird encoding, so don't extract.
+ UtfNormal::quickIsNFCVerify( $com );
+ if ( $com === $oldCom ) {
+ $segments["COM"][] = $oldCom;
+ } else {
+ wfDebug( __METHOD__ . ' Ignoring JPEG comment as is garbage.' );
}
- $segments["COM"][] = $oldCom;
} elseif ( $buffer === "\xE1" && $showXMP ) {
// APP1 section (Exif, XMP, and XMP extended)
}
if ( $this->charset !== 'UTF-8' ) {
//don't convert if already utf-8
+ wfSuppressWarnings();
$content = iconv( $this->charset, 'UTF-8//IGNORE', $content );
+ wfRestoreWarnings();
}
$ok = xml_parse( $this->xmlParser, $content, $allOfIt );