diff options
author | Jakub Zawadzki <darkjames-ws@darkjames.pl> | 2012-04-04 20:52:52 +0000 |
---|---|---|
committer | Jakub Zawadzki <darkjames-ws@darkjames.pl> | 2012-04-04 20:52:52 +0000 |
commit | c67d24077ef60cbe997467f6294f8b856351cfd4 (patch) | |
tree | b6df1d1b9974d28cf8ff401a584c0194f527cb56 | |
parent | 75c3c92f197406d14eb213e30a07955928517399 (diff) |
Allow loading xml files (file MUST start with <?xml).
I needed it for testing (bug #7028)
if you feel like it's stupid idea give me nfo :)
svn path=/trunk/; revision=41944
-rw-r--r-- | epan/dissectors/packet-xml.c | 21 | ||||
-rw-r--r-- | wiretap/mime_file.c | 6 |
2 files changed, 15 insertions, 12 deletions
diff --git a/epan/dissectors/packet-xml.c b/epan/dissectors/packet-xml.c index 921e07abd0..22d08dc9c4 100644 --- a/epan/dissectors/packet-xml.c +++ b/epan/dissectors/packet-xml.c @@ -227,18 +227,16 @@ dissect_xml(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) } static gboolean dissect_xml_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { - if (pref_heuristic_media || pref_heuristic_tcp || pref_heuristic_udp) { - if (tvbparse_peek(tvbparse_init(tvb,0,-1,NULL,want_ignore), want_heur)) { - dissect_xml(tvb, pinfo, tree); + if (tvbparse_peek(tvbparse_init(tvb,0,-1,NULL,want_ignore), want_heur)) { + dissect_xml(tvb, pinfo, tree); + return TRUE; + } else if (pref_heuristic_unicode) { + const guint8 *data = tvb_get_ephemeral_unicode_string(tvb, 0, tvb_length(tvb), ENC_LITTLE_ENDIAN); + tvbuff_t *unicode_tvb = tvb_new_child_real_data(tvb, data, tvb_length(tvb)/2, tvb_length(tvb)/2); + if (tvbparse_peek(tvbparse_init(unicode_tvb,0,-1,NULL,want_ignore), want_heur)) { + add_new_data_source(pinfo, unicode_tvb, "UTF8"); + dissect_xml(unicode_tvb, pinfo, tree); return TRUE; - } else if (pref_heuristic_unicode) { - const guint8 *data = tvb_get_ephemeral_unicode_string(tvb, 0, tvb_length(tvb), ENC_LITTLE_ENDIAN); - tvbuff_t *unicode_tvb = tvb_new_child_real_data(tvb, data, tvb_length(tvb)/2, tvb_length(tvb)/2); - if (tvbparse_peek(tvbparse_init(unicode_tvb,0,-1,NULL,want_ignore), want_heur)) { - add_new_data_source(pinfo, unicode_tvb, "UTF8"); - dissect_xml(unicode_tvb, pinfo, tree); - return TRUE; - } } } return FALSE; @@ -1417,5 +1415,6 @@ proto_reg_handoff_xml(void) xml_handle = find_dissector("xml"); g_hash_table_foreach(media_types,add_dissector_media,NULL); + heur_dissector_add("wtap_file", dissect_xml_heur, xml_ns.hf_tag); } diff --git a/wiretap/mime_file.c b/wiretap/mime_file.c index ff46ab9e7a..90eafcd9c0 100644 --- a/wiretap/mime_file.c +++ b/wiretap/mime_file.c @@ -73,8 +73,12 @@ static const guint8 jpeg_jfif_magic[] = { 0xFF, 0xD8, /* SOF */ 0xFF /* start of the next marker */ }; +/* <?xml */ +static const guint8 xml_magic[] = { '<', '?', 'x', 'm', 'l' }; + static const mime_files_t magic_files[] = { - { jpeg_jfif_magic, sizeof(jpeg_jfif_magic) } + { jpeg_jfif_magic, sizeof(jpeg_jfif_magic) }, + { xml_magic, sizeof(xml_magic) } }; #define N_MAGIC_TYPES (sizeof(magic_files) / sizeof(magic_files[0])) |