Anonymous committed a311cbd

Only display text-types with default mimeviewer. Fixes #296.

  • Participants
  • Parent commits 97c9186
  • Branches trunk

Comments (0)

Files changed (4)

 Olliver Rutherfurd  ollie
 Emmeran Seehuber
-Diggs and Lula (pawprint contributors)
+The elusive Anonymous (for wiki edits and bug reports)
+Diggs and Lula (official pawprint contributors)
 And everyone who keeps sending feedback, helping us improve Trac.

File trac/

             viewer = getattr(mimeviewers, name)
             for st in viewer.supported_types:
                 self.add_viewer (st[1], viewer, st[0])
     def add_viewer(self, type, viewer, prio=0):
         if not self.viewers.has_key(type):
             self.viewers[type] = []
         if not viewer in self.viewers[type]:
             self.viewers[type].append([prio, viewer])
     def get_viewer(self, mimetype, _idx=0):
             if mimetype:
             return self.viewers[mimetype][_idx][1], i
         except (KeyError, IndexError):
             return self.get_viewer(None)
     def get_mimetype(self, filename):
             i = filename.rfind('.')
             return mimetypes.guess_type(filename)[0]
             return None
     def display(self, data, mimetype=None, filename=None):
         if not data:
             return ''
         if filename:
             if not mimetype:
                 mimetype = self.get_mimetype(filename)
-#             elif not mimetype == 'application/octet-stream':
-#                 mimetype = self.get_mimetype(filename)
         idx = 0
         while not idx == -1:
             viewer,idx = self.get_viewer (mimetype, idx)

File trac/mimeviewers/

 def display(data, mimetype, filename, env):
     env.log.debug("Mimetype: %s   filename: %s" % (mimetype, filename))
-    if not mimetype or mimetype == 'application/octet-stream':
+    if not mimetype or not mimetype[:5] == 'text/':
         env.log.debug("Binary data. Displaying summary.")
         return ''
     env.log.debug("Using default mimeviewer")

File trac/mimeviewers/

 def display(data, mimetype, filename, env):
-    import SilverCity
     from SilverCity import LanguageInfo
         typelang = type_lang[mimetype]