Wireshark-dev: Re: [Wireshark-dev] Wireshark-dev Digest, Vol 79, Issue 6

From: Pascal Quantin <pascal.quantin@xxxxxxxxx>
Date: Tue, 4 Dec 2012 17:41:16 +0100

2012/12/4 Anders Broman <anders.broman@xxxxxxxxxxxx>
Hi,
The correct fix is to change the script make-usb.py in the tools dir to escape non ASCII chars
similarly to make-sminmpec.pl
sub escape_non_ascii {
    my $val = unpack 'C', $_[0];
    return sprintf '\0%.3o',$val;
}
and rebuild the file, then submitt a patch with the changes.

Hi,

with the following patch:
Index: tools/make-usb.py
===================================================================
--- tools/make-usb.py    (revision 46346)
+++ tools/make-usb.py    (working copy)
@@ -36,11 +36,11 @@
 
     if mode == MODE_VENDOR_PRODUCT:
         if re.match("^[0-9a-f]{4}", line):
-            vendors += "    { 0x%s, \"%s\" },\n"%(line[:4], re.sub("\"", "\\\"", re.sub("\?+", "?", line[4:].strip().replace("\\", "\\\\"))))
+            vendors += "    { 0x%s, \"%s\" },\n"%(line[:4], re.sub("\"", "\\\"", re.sub("\?+", "?", repr(line[4:].strip()).strip("'").replace("\\", "\\\\"))))
             last_vendor = line[:4]
         elif re.match("^\t[0-9a-f]{4}", line):
             line = line.strip()
-            products += "    { 0x%s%s, \"%s\" },\n"%(last_vendor, line[:4], re.sub("\"", "\\\"", re.sub("\?+", "?", line[4:].strip().replace("\\", "\\\\"))))
+            products += "    { 0x%s%s, \"%s\" },\n"%(last_vendor, line[:4], re.sub("\"", "\\\"", re.sub("\?+", "?", repr(line[4:].strip()).strip("'").replace("\\", "\\\\"))))
 
 
 vendors += """    { 0, NULL }\n};

"SideWinder® Freestyle Pro" is now displayed as "SideWinder\\xc2\\xae Freestyle Pro". I guess this is the kind of escaping you were thinking to Anders, right?

Note that I'm a newbie in Python so there might be a smarter way to do it. If nobody propose something else, I will push it as is and let the Python experts do a follow up if needed.

Pascal.