Ignore:
Timestamp:
Aug 16, 2017, 12:53:41 PM (7 years ago)
Author:
Jason Gross <jasongross9@gmail.com>
Branches:
master
Children:
ff528e6
Parents:
da7341e
git-author:
Jason Gross <jgross@mit.edu> (07/12/11 14:42:39)
git-committer:
Jason Gross <jasongross9@gmail.com> (08/16/17 12:53:41)
Message:
Moved log file name generation to perl

I don't think that the class/personal distinction is the best for
general protocols, but I don't know what should replace it.  I've made
class-logging default to only zephyr (a slight change from previous
behavior, where jabber MUC's would be logged to $classlogpath, as well
as all non-private non-login messages from other protocols), but made
logging path generation overridable.

TODO: Decide whether or not to filter out more 'bad' characters.
Perhaps we should remove '!' because it indicates history in some shells
and makes things obnoxious, or '~' becase it indicates homedirs in many
shells.
* '/' is for separating directories, and we don't want to accidentally
  make subdirectories

We first NFKC for zephyrs, and then apply lc.  The zephyr servers
apply case-folded NFKC (so says
http://zephyr.1ts.org/browser/zephyr/server/zstring.c).  We should
probably use Unicode::CaseFold instead of lc.  I'm also not sure what
the order case-adjustment and normalization should be.

We first NFKC, then apply lc, to jabbers, as per
http://xmpp.org/internet-drafts/attic/draft-ietf-xmpp-nodeprep-03.html
(though I can't actually find anything that specifies the case-folding
algorithm, nor the ordering).

We now use lc instead of g_utf8_strdown to normalize AIM screennames.
Location:
perl/lib/BarnOwl/Message
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • perl/lib/BarnOwl/Message/AIM.pm

    r7011c3dc reea7bed4  
    2424}
    2525
     26sub normalize_screenname {
     27    my ($screenname) = @_;
     28    $screenname =~ s/\s+//g;
     29    return lc($screenname);
     30}
     31
     32sub log_filenames {
     33    return map { normalize_screenname($_) } BarnOwl::Message::log_filenames(@_);
     34}
    2635
    27361;
  • perl/lib/BarnOwl/Message/Zephyr.pm

    r7f463cf reea7bed4  
    99
    1010use base qw( BarnOwl::Message );
     11use Unicode::Normalize qw( NFKC );
    1112
    1213sub strip_realm {
     
    132133    return $1 if $self->body =~ /^\s*cc:\s+([^\n]+)/i;
    133134    return undef;
     135}
     136
     137sub zephyr_cc_without_recipient {
     138    my $self = shift;
     139    my $recipient = lc(strip_realm($self->recipient));
     140    my $cc = $self->zephyr_cc;
     141    return grep { lc(strip_realm($_)) ne $recipient } split(/\s+/, $cc) if defined $cc;
     142    return ();
    134143}
    135144
     
    240249}
    241250
     251sub log_filenames {
     252    my ($m) = @_;
     253    my @filenames = ();
     254    if ($m->is_personal) {
     255        @filenames = $m->zephyr_cc_without_recipient;
     256    }
     257    if ($m->is_incoming) {
     258        if ($m->is_personal) {
     259            push @filenames, $m->sender;
     260        } else {
     261            return (lc(NFKC($m->class)));
     262        }
     263    } else {
     264        push @filenames, $m->recipient;
     265    }
     266    return map { lc(NFKC(strip_realm($_))) } @filenames;
     267}
     268
     269sub log_to_class_file {
     270    my ($m) = @_;
     271    return !$m->is_personal;
     272}
     273
     274sub log_base_path {
     275    my ($m) = @_;
     276    if ($m->log_to_class_file) {
     277        return BarnOwl::getvar('classlogpath');
     278    } else {
     279        return BarnOwl::getvar('logpath');
     280    }
     281}
     282
    2422831;
Note: See TracChangeset for help on using the changeset viewer.