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 /epan/dissectors/packet-xml.c | |
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
Diffstat (limited to 'epan/dissectors/packet-xml.c')
-rw-r--r-- | epan/dissectors/packet-xml.c | 21 |
1 files changed, 10 insertions, 11 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); } |