Index: trunk/phase3/includes/filerepo/File.php |
— | — | @@ -133,10 +133,10 @@ |
134 | 134 | * Split an internet media type into its two components; if not |
135 | 135 | * a two-part name, set the minor type to 'unknown'. |
136 | 136 | * |
137 | | - * @param $mime "text/html" etc |
| 137 | + * @param string $mime "text/html" etc |
138 | 138 | * @return array ("text", "html") etc |
139 | 139 | */ |
140 | | - static function splitMime( $mime ) { |
| 140 | + public static function splitMime( $mime ) { |
141 | 141 | if( strpos( $mime, '/' ) !== false ) { |
142 | 142 | return explode( '/', $mime, 2 ); |
143 | 143 | } else { |
Index: trunk/phase3/includes/specials/SpecialMIMEsearch.php |
— | — | @@ -75,8 +75,9 @@ |
76 | 76 | Xml::closeElement( 'form' ) |
77 | 77 | ); |
78 | 78 | |
79 | | - list( $this->major, $this->minor ) = self::parseMIME( $mime ); |
80 | | - if ( $this->major == '' || $this->minor == '' || !self::isValidType( $this->major ) ) { |
| 79 | + list( $this->major, $this->minor ) = File::splitMime( $mime ); |
| 80 | + if ( $this->major == '' || $this->minor == '' || $this->minor == 'unknown' || |
| 81 | + !self::isValidType( $this->major ) ) { |
81 | 82 | return; |
82 | 83 | } |
83 | 84 | parent::execute( $par ); |
— | — | @@ -105,21 +106,7 @@ |
106 | 107 | |
107 | 108 | return "($download) $plink . . $dimensions . . $bytes . . $user . . $time"; |
108 | 109 | } |
109 | | - |
110 | | - protected static function parseMIME( $str ) { |
111 | | - // searched for an invalid MIME type. |
112 | | - if( strpos( $str, '/' ) === false ) { |
113 | | - return array( '', '' ); |
114 | | - } |
115 | 110 | |
116 | | - list( $major, $minor ) = explode( '/', $str, 2 ); |
117 | | - |
118 | | - return array( |
119 | | - ltrim( $major, ' ' ), |
120 | | - rtrim( $minor, ' ' ) |
121 | | - ); |
122 | | - } |
123 | | - |
124 | 111 | protected static function isValidType( $type ) { |
125 | 112 | // From maintenance/tables.sql => img_major_mime |
126 | 113 | $types = array( |