[bugzilla-gnome-org-extensions] Deal with UTF-8 in the traces.



commit 6a4b6560188ed2313a4cdc36f3c91c284f095bb9
Author: Max Kanat-Alexander <mkanat everythingsolved com>
Date:   Wed Aug 5 07:01:41 2009 -0500

    Deal with UTF-8 in the traces.

 lib/TraceParser/Trace.pm |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/lib/TraceParser/Trace.pm b/lib/TraceParser/Trace.pm
index 8cc96e9..5fd3c60 100644
--- a/lib/TraceParser/Trace.pm
+++ b/lib/TraceParser/Trace.pm
@@ -132,11 +132,11 @@ sub parse_from_text {
         my $max_short_stack = $#all_functions >= STACK_SIZE ? STACK_SIZE 
                               : $#all_functions;
         my @short_stack = @all_functions[0..($max_short_stack-1)];
-        $stack_hash = md5_base64(join(',', @all_functions));
-        $short_hash = md5_base64(join(',', @short_stack));
+        $stack_hash = _hash(join(',', @all_functions));
+        $short_hash = _hash(join(',', @short_stack));
     }
     my $trace_text = $trace->text;
-    my $trace_hash = md5_base64($trace_text);
+    my $trace_hash = _hash($trace_text);
 
     return {
         stack_hash  => $stack_hash,
@@ -148,6 +148,12 @@ sub parse_from_text {
     };
 }
 
+sub _hash {
+    my $str = shift;
+    utf8::encode($str) if utf8::is_utf8($str);
+    return md5_base64($str);
+}
+
 ###############################
 ####      Accessors      ######
 ###############################


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]