]> git.donarmstrong.com Git - infobot.git/blobdiff - src/Factoids/Statement.pl
avoid reassigning to temp upon decode_utf8
[infobot.git] / src / Factoids / Statement.pl
index 48b10cb70944afcd70ce7c6bc0b2e95c8afec48a..1cc50cb98c47a7fa6e1e4dbe2feb8ba021f999c2 100644 (file)
@@ -15,6 +15,8 @@
 
 # use strict;  # TODO
 
+use Encode qw(decode_utf8);
+
 sub doStatement {
     my ($in) = @_;
 
@@ -116,16 +118,15 @@ sub doStatement {
         # verify the update statement whether there are any weird
         # characters.
         ### this can be simplified.
-        foreach ( split //, $lhs . $rhs ) {
-            my $ord = ord $_;
-            if ( $ord > 170 and $ord < 220 ) {
-                &status("statement: illegal character '$_' $ord.");
+        for my $temp ($lhs,$rhs ) {
+           my $temp2 = decode_utf8($temp);
+           if ($temp2 =~ /([^[:print:]])/ or $temp2 =~ /\N{U+FFFD}/) {
+               &status("statement: illegal character '$1' ".ord($1).".");
                 &performAddressedReply(
                     "i'm not going to learn illegal characters");
                 return;
             }
         }
-
         # success.
         return if ( &update( $lhs, $mhs, $rhs ) );
     }