diff --git a/src/registry.jl b/src/registry.jl index 189e6bf..7592281 100644 --- a/src/registry.jl +++ b/src/registry.jl @@ -461,9 +461,7 @@ function detect_stlbinary(io) number_of_triangle_blocks = read(io, UInt32) #1 normal, 3 vertices in Float32 + attrib count, usually 0 len != (number_of_triangle_blocks*size_triangleblock)+size_header && (seekstart(io); return false) - skip(io, number_of_triangle_blocks*size_triangleblock-sizeof(UInt16)) - attrib_byte_count = read(io, UInt16) # read last attrib_byte - attrib_byte_count != zero(UInt16) && (seekstart(io); return false) # should be zero as not used + skip(io, number_of_triangle_blocks*size_triangleblock) result = eof(io) # if end of file, we have a stl! return result end diff --git a/test/files/binary_stl_with_nonzero_attribute_byte_count.stl b/test/files/binary_stl_with_nonzero_attribute_byte_count.stl new file mode 100644 index 0000000..f797f35 Binary files /dev/null and b/test/files/binary_stl_with_nonzero_attribute_byte_count.stl differ diff --git a/test/query.jl b/test/query.jl index a4b08bd..4024af0 100644 --- a/test/query.jl +++ b/test/query.jl @@ -358,6 +358,9 @@ let file_dir = joinpath(@__DIR__, "files"), file_path = Path(file_dir) @test typeof(q) <: File{format"STL_ASCII"} q = query(joinpath(file_dir, "binary_stl_from_solidworks.STL")) @test typeof(q) <: File{format"STL_BINARY"} + # See Pull Request # 388 + q = query(joinpath(file_dir, "binary_stl_with_nonzero_attribute_byte_count.stl")) + @test typeof(q) <: File{format"STL_BINARY"} open(q) do io @test position(io) == 0 skipmagic(io)