From 9529cd2071491fc823eb5139748b97a3887c51f9 Mon Sep 17 00:00:00 2001 From: HummyPkg Date: Wed, 3 May 2017 23:35:30 +0100 Subject: [PATCH] make classdump binary-safe --- webif/lib/classdump | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/webif/lib/classdump b/webif/lib/classdump index 38f3c4e..6a70c5b 100644 --- a/webif/lib/classdump +++ b/webif/lib/classdump @@ -1,8 +1,23 @@ if {![exists -proc classdump]} { + proc _classdump_escape {data} { + if {[string is print $data]} { return $data } + set ret "" + foreach c [split $data ""] { + if {[string is print $c]} { + append ret $c + } else { + binary scan $c H* hex + append ret "\\x$hex" + } + } + return $ret + } + proc classdump {o} { foreach var [$o vars] { - puts [format {%20s %s} $var [$o get $var]] + puts [format {%20s %s} $var [\ + _classdump_escape [$o get $var]]] } } }