]> git.ipfire.org Git - people/ms/ipfire-2.x.git/commitdiff
firewall: Allow remarks in Unicode.
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 5 Mar 2014 12:59:28 +0000 (13:59 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 5 Mar 2014 12:59:28 +0000 (13:59 +0100)
html/cgi-bin/firewall.cgi

index e633b3c5c291c713ad851231c2305d297a8d2c33..7bcb07964e6efabbce88246cb60feafacc4f7389 100644 (file)
 
 use strict;
 use Sort::Naturally;
+use utf8;
+use feature 'unicode_strings';
+
 no warnings 'uninitialized';
+
 # enable only the following on debugging purpose
 #use warnings;
 #use CGI::Carp 'fatalsToBrowser';
@@ -2142,6 +2146,7 @@ sub saverule
                        #print"6";
                }
                $fwdfwsettings{'ruleremark'}=~ s/,/;/g;
+               utf8::decode($fwdfwsettings{'ruleremark'});
                $fwdfwsettings{'ruleremark'}=&Header::escape($fwdfwsettings{'ruleremark'});
                if ($fwdfwsettings{'updatefwrule'} ne 'on'){
                        my $key = &General::findhasharraykey ($hash);
@@ -2279,6 +2284,14 @@ sub validremark
 {
        # Checks a hostname against RFC1035
        my $remark = $_[0];
+
+       # Try to decode $remark into UTF-8. If this doesn't work,
+       # we assume that the string it not sane.
+       if (!utf8::decode($remark)) {
+               return 0;
+       }
+
+       # Check if the string only contains of printable characters.
        if ($remark =~ /^[[:print:]]*$/) {
                return 1;
        }