Index: trunk/phase3/includes/media/Exif.php |
— | — | @@ -435,13 +435,17 @@ |
436 | 436 | // This could possibly check to see if iconv is really installed |
437 | 437 | // or if we're using the compatibility wrapper in globalFunctions.php |
438 | 438 | if ($charset) { |
| 439 | + wfSuppressWarnings(); |
439 | 440 | $val = iconv($charset, 'UTF-8//IGNORE', $val); |
| 441 | + wfRestoreWarnings(); |
440 | 442 | } else { |
441 | 443 | // if valid utf-8, assume that, otherwise assume windows-1252 |
442 | 444 | $valCopy = $val; |
443 | 445 | UtfNormal::quickIsNFCVerify( $valCopy ); //validates $valCopy. |
444 | 446 | if ( $valCopy !== $val ) { |
| 447 | + wfSuppressWarnings(); |
445 | 448 | $val = iconv('Windows-1252', 'UTF-8//IGNORE', $val); |
| 449 | + wfRestoreWarnings(); |
446 | 450 | } |
447 | 451 | } |
448 | 452 | |
Index: trunk/phase3/includes/media/IPTC.php |
— | — | @@ -418,7 +418,9 @@ |
419 | 419 | */ |
420 | 420 | private static function convIPTCHelper ( $data, $charset ) { |
421 | 421 | if ( $charset ) { |
| 422 | + wfSuppressWarnings(); |
422 | 423 | $data = iconv($charset, "UTF-8//IGNORE", $data); |
| 424 | + wfRestoreWarnings(); |
423 | 425 | if ($data === false) { |
424 | 426 | $data = ""; |
425 | 427 | wfDebugLog('iptc', __METHOD__ . " Error converting iptc data charset $charset to utf-8"); |
Index: trunk/phase3/includes/media/XMP.php |
— | — | @@ -260,7 +260,9 @@ |
261 | 261 | } |
262 | 262 | if ( $this->charset !== 'UTF-8' ) { |
263 | 263 | //don't convert if already utf-8 |
| 264 | + wfSuppressWarnings(); |
264 | 265 | $content = iconv( $this->charset, 'UTF-8//IGNORE', $content ); |
| 266 | + wfRestoreWarnings(); |
265 | 267 | } |
266 | 268 | |
267 | 269 | $ok = xml_parse( $this->xmlParser, $content, $allOfIt ); |
Index: trunk/phase3/includes/media/JpegMetadataExtractor.php |
— | — | @@ -56,14 +56,22 @@ |
57 | 57 | // First see if valid utf-8, |
58 | 58 | // if not try to convert it to windows-1252. |
59 | 59 | $com = $oldCom = trim( self::jpegExtractMarker( $fh ) ); |
60 | | - |
61 | 60 | UtfNormal::quickIsNFCVerify( $com ); |
62 | 61 | // turns $com to valid utf-8. |
63 | 62 | // thus if no change, its utf-8, otherwise its something else. |
64 | 63 | if ( $com !== $oldCom ) { |
65 | | - $oldCom = iconv( 'windows-1252', 'UTF-8//IGNORE', $oldCom ); |
| 64 | + wfSuppressWarnings(); |
| 65 | + $com = $oldCom = iconv( 'windows-1252', 'UTF-8//IGNORE', $oldCom ); |
| 66 | + wfRestoreWarnings(); |
66 | 67 | } |
67 | | - $segments["COM"][] = $oldCom; |
| 68 | + // Try it again, if its still not a valid string, then probably |
| 69 | + // binary junk or some really weird encoding, so don't extract. |
| 70 | + UtfNormal::quickIsNFCVerify( $com ); |
| 71 | + if ( $com === $oldCom ) { |
| 72 | + $segments["COM"][] = $oldCom; |
| 73 | + } else { |
| 74 | + wfDebug( __METHOD__ . ' Ignoring JPEG comment as is garbage.' ); |
| 75 | + } |
68 | 76 | |
69 | 77 | } elseif ( $buffer === "\xE1" && $showXMP ) { |
70 | 78 | // APP1 section (Exif, XMP, and XMP extended) |