Check preference titles and descriptions.
authorGerald Combs <gerald@wireshark.org>
Tue, 20 Sep 2016 21:11:29 +0000 (14:11 -0700)
committerMichael Mann <mmann78@netscape.net>
Thu, 1 Dec 2016 01:26:39 +0000 (01:26 +0000)
When registering preferences, make sure our titles and descriptions are
valid UTF-8. Make sure our titles are short and only contain printable
characters.

Fix problematic titles and descriptions.

Change-Id: I20d3f93438f2b3c30266f934297feb79897f2ee5
Reviewed-on: https://code.wireshark.org/review/18998
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
14 files changed:
epan/dissectors/asn1/snmp/packet-snmp-template.c
epan/dissectors/packet-cp2179.c
epan/dissectors/packet-diameter.c
epan/dissectors/packet-distcc.c
epan/dissectors/packet-eth.c
epan/dissectors/packet-ieee80211.c
epan/dissectors/packet-ipv6.c
epan/dissectors/packet-iscsi.c
epan/dissectors/packet-rpc.c
epan/dissectors/packet-rtsp.c
epan/dissectors/packet-smtp.c
epan/dissectors/packet-snmp.c
epan/prefs.c
epan/prefs.h

index 90d0a3aebe7a010aa507171bc0e1f4b3b238856a..7e4ade2470d4d492b4f2667ca53d49b8da7dc9bc 100644 (file)
@@ -2540,7 +2540,7 @@ void proto_register_snmp(void) {
        prefs_register_obsolete_preference(snmp_module, "users_file");
 
        prefs_register_bool_preference(snmp_module, "desegment",
-                       "Reassemble SNMP-over-TCP messages\nspanning multiple TCP segments",
+                       "Reassemble SNMP-over-TCP messages spanning multiple TCP segments",
                        "Whether the SNMP dissector should reassemble messages spanning multiple TCP segments."
                        " To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
                        &snmp_desegment);
index f43e5a6075072e746dfe52b139f66949b546d673..d3d5ae8197f0581fc9d20f73e1b8682db8df55f6 100644 (file)
@@ -1363,7 +1363,7 @@ proto_register_cp2179(void)
 
     /* Telnet protocol IAC (0xFF) processing; defaults to TRUE to allow Telnet Encapsulated Data */
     prefs_register_bool_preference(cp2179_module, "telnetclean",
-                                  "Enable Automatic pre-processing of Telnet-encapsulated data to remove extra 0xFF (IAC) bytes",
+                                  "Remove extra 0xFF (IAC) bytes from Telnet-encapsulated data",
                                   "Whether the SEL Protocol dissector should automatically pre-process Telnet data to remove IAC bytes",
                                   &cp2179_telnet_clean);
 
index 706bf05bfa038050405c4a2c42346b9578b06153..55011ac2012f4d4de2eb18e412710927918268c3 100644 (file)
@@ -2345,7 +2345,7 @@ proto_register_diameter(void)
 
        /* Desegmentation */
        prefs_register_bool_preference(diameter_module, "desegment",
-                                      "Reassemble Diameter messages\nspanning multiple TCP segments",
+                                      "Reassemble Diameter messages spanning multiple TCP segments",
                                       "Whether the Diameter dissector should reassemble messages spanning multiple TCP segments."
                                       " To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
                                       &gbl_diameter_desegment);
index 44a1ca936b303bdad70183d97918ff62ef65d5d3..7903ae58069809965b4fe9f766d01b380d9f5d00 100644 (file)
@@ -367,7 +367,7 @@ proto_register_distcc(void)
     distcc_module = prefs_register_protocol(proto_distcc, NULL);
 
     prefs_register_bool_preference(distcc_module, "desegment_distcc_over_tcp",
-        "Reassemble DISTCC-over-TCP messages\nspanning multiple TCP segments",
+        "Reassemble DISTCC-over-TCP messages spanning multiple TCP segments",
         "Whether the DISTCC dissector should reassemble messages spanning multiple TCP segments."
         " To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
         &distcc_desegment);
index b07726fb4f0feb04e5add34b3b9e5efa019fb12a..fc834c57590324737086930e99836e8e09e9988c 100644 (file)
@@ -965,11 +965,11 @@ proto_register_eth(void)
                                  &eth_interpret_as_fw1_monitor);
 
   prefs_register_static_text_preference(eth_module, "ccsds_heuristic",
+                                        "Dissect as CCSDS if",
                                         "These are the conditions to match a payload against in order to determine if this\n"
                                         "is a CCSDS (Consultative Committee for Space Data Systems) packet within\n"
                                         "an 802.3 packet. A packet is considered as a possible CCSDS packet only if\n"
-                                        "one or more of the conditions are checked.",
-                                        "Describe the conditions that must be true for the CCSDS dissector to be called");
+                                        "one or more of the conditions are checked.");
 
   prefs_register_bool_preference(eth_module, "ccsds_heuristic_length",
                                  "CCSDS Length in header matches payload size",
index 5707251f0715f259b2b2bfed09d59ef19f926f80..f83929328b803c528bbdbf6320a64fbb72b103c5 100644 (file)
@@ -27420,14 +27420,6 @@ proto_register_ieee80211(void)
     "Enable decryption", "Enable WEP and WPA/WPA2 decryption",
     &enable_decryption);
 
-  prefs_register_static_text_preference(wlan_module, "info_decryption_key",
-    "Key examples: 01:02:03:04:05 (40/64-bit WEP),\n"
-    "010203040506070809101111213 (104/128-bit WEP),\n"
-    "MyPassword[:MyAP] (WPA + plaintext password [+ SSID]),\n"
-    "0102030405...6061626364 (WPA + 256-bit key).  "
-    "Invalid keys will be ignored.",
-    "Valid key formats");
-
   wep_uat = uat_new("WEP and WPA Decryption Keys",
             sizeof(uat_wep_key_record_t), /* record size */
             "80211_keys",                 /* filename */
@@ -27435,7 +27427,7 @@ proto_register_ieee80211(void)
             &uat_wep_key_records,         /* data_ptr */
             &num_wepkeys_uat,             /* numitems_ptr */
             UAT_AFFECTS_DISSECTION,       /* affects dissection of packets, but not set of named fields */
-            NULL,                         /* help */
+            NULL,                         /* help. XXX Needs chapter in WSUG */
             uat_wep_key_record_copy_cb,   /* copy callback */
             uat_wep_key_record_update_cb, /* update callback */
             uat_wep_key_record_free_cb,   /* free callback */
@@ -27444,8 +27436,13 @@ proto_register_ieee80211(void)
 
   prefs_register_uat_preference(wlan_module,
                                 "wep_key_table",
-                                "Decryption Keys",
-                                "WEP and pre-shared WPA keys",
+                                "Decryption keys",
+                                "WEP and pre-shared WPA keys\n"
+                                "Key examples: 01:02:03:04:05 (40/64-bit WEP),\n"
+                                "010203040506070809101111213 (104/128-bit WEP),\n"
+                                "MyPassword[:MyAP] (WPA + plaintext password [+ SSID]),\n"
+                                "0102030405...6061626364 (WPA + 256-bit key)."
+                                "Invalid keys will be ignored.",
                                 wep_uat);
 }
 
index 922c9f8bd189509b6b5becddcfed915fc52319b8..c5f603bb3e76e3600ba0e39eb6d267a8b1fd541c 100644 (file)
@@ -3501,8 +3501,8 @@ proto_register_ipv6(void)
 
     /* RPL Strict Header Checking */
     prefs_register_bool_preference(ipv6_module, "perform_strict_rpl_srh_rfc_checking",
-                                   "Perform strict checking for adherence to the RFC for RPL Source Routing Headers (RFC 6554)",
-                                   "Whether to check that all RPL Source Routed packets do not visit a node more than once",
+                                   "Perform strict checking for RPL Source Routing Headers (RFC 6554)",
+                                   "Check that all RPL Source Routed packets conform to RFC 6554 and do not visit a node more than once",
                                    &g_ipv6_rpl_srh_strict_rfc_checking);
 
     prefs_register_bool_preference(ipv6_module, "try_heuristic_first",
index fd8e00fbefa61250a9a7f24cd5917fc87282f8b7..f5d44d6f53aa542cfe64f8a2e25ae8ed7f6476e7 100644 (file)
@@ -3107,7 +3107,7 @@ proto_register_iscsi(void)
 
     prefs_register_bool_preference(iscsi_module,
                                    "desegment_iscsi_messages",
-                                   "Reassemble iSCSI messages\nspanning multiple TCP segments",
+                                   "Reassemble iSCSI messages spanning multiple TCP segments",
                                    "Whether the iSCSI dissector should reassemble messages spanning multiple TCP segments."
                                    " To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
                                    &iscsi_desegment);
index e6bd7fa9caf3f2708f14648a081c6688611c38af..cac55c1119bccc1156ac7cb0327df0850673997f 100644 (file)
@@ -4375,7 +4375,7 @@ proto_register_rpc(void)
 
        rpc_module = prefs_register_protocol(proto_rpc, NULL);
        prefs_register_bool_preference(rpc_module, "desegment_rpc_over_tcp",
-           "Reassemble RPC over TCP messages\nspanning multiple TCP segments",
+           "Reassemble RPC over TCP messages spanning multiple TCP segments",
            "Whether the RPC dissector should reassemble messages spanning multiple TCP segments."
            " To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
                &rpc_desegment);
index 063251d193ca02e152ad5b1b16b6ea55f7c9c6ad..d4f95a84537cc932c98213ddc0f9e4162838cacb 100644 (file)
@@ -1489,8 +1489,7 @@ proto_register_rtsp(void)
         " To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
         &rtsp_desegment_headers);
     prefs_register_bool_preference(rtsp_module, "desegment_body",
-        "Trust the \"Content-length:\" header and\ndesegment RTSP "
-        "bodies\nspanning multiple TCP segments",
+        "Trust the \"Content-length:\" header when desegmenting",
         "Whether the RTSP dissector should use the "
         "\"Content-length:\" value to desegment the body "
         "of a request spanning multiple TCP segments",
index c99c582a148cde35d51aded554ae3fb63eae1c83..8b9f367e9e90d122d3a62b41620c5216bc888816 100644 (file)
@@ -1292,7 +1292,7 @@ proto_register_smtp(void)
   /* Preferences */
   smtp_module = prefs_register_protocol(proto_smtp, NULL);
   prefs_register_bool_preference(smtp_module, "desegment_lines",
-                                 "Reassemble SMTP command and response lines\nspanning multiple TCP segments",
+                                 "Reassemble SMTP command and response lines spanning multiple TCP segments",
                                  "Whether the SMTP dissector should reassemble command and response lines"
                                  " spanning multiple TCP segments. To use this option, you must also enable "
                                  "\"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
index e8774b84c8b0915598d2d125708be28e4f9ee023..3d51523d66a9c7bdec24fee186f858382176b2d0 100644 (file)
@@ -4038,7 +4038,7 @@ void proto_register_snmp(void) {
        prefs_register_obsolete_preference(snmp_module, "users_file");
 
        prefs_register_bool_preference(snmp_module, "desegment",
-                       "Reassemble SNMP-over-TCP messages\nspanning multiple TCP segments",
+                       "Reassemble SNMP-over-TCP messages spanning multiple TCP segments",
                        "Whether the SNMP dissector should reassemble messages spanning multiple TCP segments."
                        " To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
                        &snmp_desegment);
index 43eec4d726f9f11def02872d267fe46f011d36b2..ee227896a16a0041a0776c7bcfd32c3c4f797d50 100644 (file)
@@ -787,6 +787,7 @@ register_preference(module_t *module, const char *name, const char *title,
 {
     pref_t *preference;
     const gchar *p;
+    const char *name_prefix = (module->name != NULL) ? module->name : module->parent->name;
 
     preference = g_new(pref_t,1);
     preference->name = name;
@@ -834,9 +835,32 @@ register_preference(module_t *module, const char *name, const char *title,
             g_error("Preference %s begins with the module name", name);
     }
 
+    /* The title shows up in the preferences dialog. Make sure it's UI-friendly. */
+    if (preference->title) {
+        const char *cur_char;
+        if (preference->type != PREF_STATIC_TEXT && strlen(preference->title) > 80) { // Arbitrary.
+            g_error("Title for preference %s.%s is too long: %s", name_prefix, preference->name, preference->title);
+        }
+
+        if (!g_utf8_validate(preference->title, -1, NULL)) {
+            g_error("Title for preference %s.%s isn't valid UTF-8.", name_prefix, preference->name);
+        }
+
+        for (cur_char = preference->title; *cur_char; cur_char = g_utf8_next_char(cur_char)) {
+            if (!g_unichar_isprint(g_utf8_get_char(cur_char))) {
+                g_error("Title for preference %s.%s isn't printable UTF-8.", name_prefix, preference->name);
+            }
+        }
+    }
+
+    if (preference->description) {
+        if (!g_utf8_validate(preference->description, -1, NULL)) {
+            g_error("Description for preference %s.%s isn't valid UTF-8.", name_prefix, preference->name);
+        }
+    }
+
     /*
-     * There isn't already one with that name, so add the
-     * preference.
+     * We passed all of our checks. Add the preference.
      */
     module->prefs = g_list_append(module->prefs, preference);
     if (title != NULL)
@@ -2436,13 +2460,15 @@ prefs_register_modules(void)
                        (gint*)(void*)(&prefs.gui_version_placement), gui_version_placement_type, FALSE);
 
     prefs_register_bool_preference(gui_module, "auto_scroll_on_expand",
-                                   "Automatically scroll the recently expanded item",
-                                   "Automatically scroll the recently expanded item",
+                                   "Automatically scroll packet details",
+                                   "When selecting a new packet, automatically scroll"
+                                   "to the packet detail item that matches the most"
+                                   "recently selected item",
                                    &prefs.gui_auto_scroll_on_expand);
 
     prefs_register_uint_preference(gui_module, "auto_scroll_percentage",
-                                   "The percentage down the view the recently expanded item should be scrolled",
-                                   "The percentage down the view the recently expanded item should be scrolled",
+                                   "Packet detail scroll percentage",
+                                   "The percentage down the view the recently expanded detail item should be scrolled",
                                    10,
                                    &prefs.gui_auto_scroll_percentage);
 
@@ -5357,6 +5383,7 @@ write_pref(gpointer data, gpointer user_data)
     int type;
 
     type = pref->type;
+
     if (IS_PREF_OBSOLETE(type)) {
         /*
          * This preference is no longer supported; it's not a
index 912037431a5b8b807f7988969cad91f2453f3f77..a64d363e58e3d1c37cb84042c08cc9993ac57a3a 100644 (file)
@@ -420,9 +420,17 @@ WS_DLL_PUBLIC pref_t *prefs_find_preference(module_t * module, const char *pref)
 WS_DLL_PUBLIC void prefs_register_uint_preference(module_t *module, const char *name,
     const char *title, const char *description, guint base, guint *var);
 
+/*
+ * prefs_register_ callers must conform to the following:
+ *
+ * Names must be in lowercase letters only (underscore allowed).
+ * Titles and descriptions must be valid UTF-8 or NULL.
+ * Titles must be short (less than 80 characters)
+ * Titles must not contain newlines.
+ */
+
 /*
  * Register a preference with an Boolean value.
- * Note that the name must be in lowercase letters only (underscore allowed).
  */
 WS_DLL_PUBLIC void prefs_register_bool_preference(module_t *module, const char *name,
     const char *title, const char *description, gboolean *var);