// XML formats we sure hope we recognize reliably
'svg',
+
+ // 3D formats
+ 'stl',
];
return in_array( strtolower( $extension ), $types );
}
return $this->detectZipType( $head, $tail, $ext );
}
+ // Check for STL (3D) files
+ // @see https://en.wikipedia.org/wiki/STL_(file_format)
+ if ( $fsize >= 15 &&
+ stripos( $head, 'SOLID ' ) === 0 &&
+ preg_match( '/\RENDSOLID .*$/i', $tail ) ) {
+ // ASCII STL file
+ return 'application/sla';
+ } elseif ( $fsize > 84 ) {
+ // binary STL file
+ $triangles = substr( $head, 80, 4 );
+ $triangles = unpack( 'V', $triangles );
+ $triangles = reset( $triangles );
+ if ( $triangles !== false && $fsize === 84 + ( $triangles * 50 ) ) {
+ return 'application/sla';
+ }
+ }
+
MediaWiki\suppressWarnings();
$gis = getimagesize( $file );
MediaWiki\restoreWarnings();