           url: match[2][1...-1]
 
   processCites = (tex) ->
+    return tex unless tex
     tex.replace /\\cite\s*(?:\[([^\[\]]*)\]\s*)?{([^{}]*)}/g, (match, p1, p2) ->
       '[' + (
         for cite in p2.split ','

  unless importer?
    console.warn "Unrecognized import format '#{format}'"
    return
  for file in files
    reader = new FileReader
    reader.onload = (e) ->
      importer group, e.target.result
    reader["readAs#{importer.readAs}"] file

      for message in messages
        attach = []
        message.body = message.body
        .replace /\\ref\s*{([^{}]*)}/g, (match, ref) ->
          if ref of labels
            labels[ref]
          else if ref of figures
            attach.push figures[ref]
            #"``#{figures[ref].labels[figures[p1].labels.length-1]}''"
            "``#{ref}''"
          else
            console.warn "Unresolved #{match}"
            match
