Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[irclog] clear non-printable characters from the logs before any

other output processing to prevent bogus \b matches


git-svn-id: http://svn.pugscode.org/pugs/misc/irclog@17216 c213334d-75ef-0310-aa23-eaa082d1ae64
  • Loading branch information...
commit ae70aa713732747968d76d72fa9448c489d77700 1 parent f95c694
moritz authored
Showing with 12 additions and 5 deletions.
  1. +6 −1 IrcLog/WWW.pm
  2. +3 −1 cgi/search.pl
  3. +1 −1  ilbot.pl
  4. +2 −2 util/to-utf8.pl
View
7 IrcLog/WWW.pm
@@ -230,6 +230,11 @@ my $re_links = qr/(?!)/;
}
my %output_chain = (
+ nonprint_clean => {
+ re => qr/[^\x{90}\x{0A}\x{0D}\x{20}-\x{D7FF}\x{E000}-\x{FFFD}\x{10000}-\x{10FFFF}]+/,
+ match => q{},
+ rest => 'links',
+ },
links => {
re => qr/$RE{URI}{HTTP}(?:#[\w_%:-]+)?/,
match => \&linkify,
@@ -341,7 +346,7 @@ sub message_line {
my %h = (
ID => $args_ref->{id},
TIME => format_time($args_ref->{timestamp}),
- MESSAGE => output_process(my_decode($args_ref->{message}), "links", $args_ref->{channel}),
+ MESSAGE => output_process(my_decode($args_ref->{message}), "nonprint_clean", $args_ref->{channel}),
LINE_NUMBER => ++$args_ref->{line_number},
LINK_URL => $args_ref->{link_url},
);
View
4 cgi/search.pl
@@ -58,7 +58,9 @@
}
my $nick = decode('utf8', $q->param('nick') || '');
-my $qs = decode('utf8', $q->param('q') || '');
+#my $qs = decode('utf8', $q->param('q') || '');
+my $qs = $q->param('q') || '';
+warn "Search string: <$qs>\n";
$t->param(NICK => encode('utf8', $nick));
$t->param(Q => encode('utf8', $qs));
View
2  ilbot.pl
@@ -32,7 +32,7 @@
sub dbwrite {
my @args = @_;
- $args[-1] = encode('utf8', my_decode($args[-1]));
+ $args[-1] = my_decode($args[-1]);
# my $line = $args[-1];
# $line = encode('utf8', my_decode($line));
# print "$args[2]: $line\n";
View
4 util/to-utf8.pl
@@ -6,7 +6,7 @@
use Encode qw(encode);
my $dbh = get_dbh;
-$dbh->do("ALTER TABLE irclog charset=utf8");
+#$dbh->do("ALTER TABLE irclog charset=utf8");
my $read = $dbh->prepare('SELECT id, line FROM irclog');
my $write = $dbh->prepare('UPDATE irclog SET line = ? WHERE id = ?');
@@ -14,7 +14,7 @@
$read->execute();
my $c = 0;
while (my ($id, $line) = $read->fetchrow_array()){
- $write->execute(encode('utf8', my_decode($line)), $id);
+ $write->execute(my_decode($line), $id);
$c++;
if ($c % 1000 == 0){
print "Count: $c\n";
Please sign in to comment.
Something went wrong with that request. Please try again.