11require "uuidtools"
22require "base64"
3- require "mime/types "
3+ require "marcel "
44require "fileutils"
55require "vectory"
66
@@ -21,7 +21,7 @@ def mime_preamble(boundary, filename, result)
2121 end
2222
2323 def mime_attachment ( boundary , _filename , item , dir )
24- content_type = mime_type ( item )
24+ content_type = mime_type ( File . join ( dir , item ) )
2525 text_mode = %w[ text application ] . any? { |p | content_type . start_with? p }
2626
2727 path = File . join ( dir , item )
@@ -41,9 +41,9 @@ def mime_attachment(boundary, _filename, item, dir)
4141 end
4242
4343 def mime_type ( item )
44- types = MIME :: Types . type_for ( item )
45- type = types ? types . first . to_s : 'text/plain; charset="utf-8"'
46- type = %(#{ type } charset="utf-8") if /^text/ . match ( type ) && types
44+ type = Marcel :: MimeType . for Pathname . new ( item ) ||
45+ 'text/plain; charset="utf-8"'
46+ type = %(#{ type } charset="utf-8") if /^text/ . match? ( type )
4747 type
4848 end
4949
@@ -59,7 +59,6 @@ def mime_package(result, filename, dir)
5959 Dir . foreach ( dir ) do |item |
6060 next if item == "." || item == ".." || /^\. / . match ( item ) ||
6161 item == "filelist.xml"
62-
6362 mhtml += mime_attachment ( boundary , "#{ filename } .htm" , item , dir )
6463 end
6564 mhtml += "--#{ boundary } --"
0 commit comments