Index: epan/dissectors/packet-ftp.c =================================================================== --- epan/dissectors/packet-ftp.c (revision 43923) +++ epan/dissectors/packet-ftp.c (working copy) @@ -634,21 +634,31 @@ tvb_reported_length(tvb)); if (tree) { + gboolean is_text = TRUE; + gint check_chars, i; data_length = tvb_length(tvb); ti = proto_tree_add_item(tree, proto_ftp_data, tvb, 0, -1, ENC_NA); ftp_data_tree = proto_item_add_subtree(ti, ett_ftp_data); - /* - * tvb_format_text() is very slow for long (binary...) lines, so limit to - * size that will actually be displayed. - * - * Not clear if its really worth doing this for binary data, as bytes are not - * even shown as hex! - */ - proto_tree_add_text(ftp_data_tree, tvb, 0, data_length, - "FTP Data: %s", tvb_format_text(tvb, 0, MIN(data_length, ITEM_LABEL_LENGTH))); + /* Check the first few chars to see whether it looks like a text file or not */ + check_chars = MIN(10, data_length); + for (i=0; i < check_chars; i++) { + if (!isprint(tvb_get_guint8(tvb, i))) { + is_text = FALSE; + break; + } + } + + if (is_text) { + /* Show as string, but don't format more text than will be displayed */ + proto_item_append_text(ti, " (%s)", tvb_format_text(tvb, 0, MIN(data_length, ITEM_LABEL_LENGTH))); + } + else { + /* Assume binary, just show the number of bytes */ + proto_item_append_text(ti, " (%u bytes data)", data_length); + } } }