Ignore:
Timestamp:
Aug 16, 2017, 12:53:41 PM (7 years ago)
Author:
Jason Gross <jasongross9@gmail.com>
Branches:
master
Children:
5dee79a
Parents:
47225c9
git-author:
Jason Gross <jgross@mit.edu> (01/01/14 20:59:51)
git-committer:
Jason Gross <jasongross9@gmail.com> (08/16/17 12:53:41)
Message:
Use g_utf8_casefold and g_utf8_normalize

We define a convenience function compat_casefold in util.c for reuse in
filters.
File:
1 edited

Legend:

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

    rdce72c1 rd2ba33c  
    99
    1010use base qw( BarnOwl::Message );
    11 use Unicode::Normalize qw( NFKC );
    1211
    1312sub strip_realm {
     
    2221    my ($user, $realm) = split(/@/,$principal);
    2322    return $realm;
     23}
     24
     25sub casefold_principal {
     26    my $principal = shift;
     27    # split the principal right after the final @, without eating any
     28    # characters; this way, we always get at least '@' in $user
     29    my ($user, $realm) = split(/(?<=@)(?=[^@]+$)/, $principal);
     30    return lc($user) . uc($realm);
    2431}
    2532
     
    261268            my $realm = '';
    262269            $realm .= '@' . $m->realm if $m->realm ne BarnOwl::zephyr_getrealm();
    263             return (lc(NFKC($m->class)) . $realm);
     270            return (BarnOwl::compat_casefold($m->class) . uc($realm));
    264271        }
    265272    } else {
    266273        push @filenames, $m->recipient;
    267274    }
    268     return map { lc(NFKC(BarnOwl::zephyr_smartstrip_user(strip_realm($_)))) } @filenames;
     275    return map { casefold_principal(BarnOwl::zephyr_smartstrip_user(strip_realm($_))) } @filenames;
    269276}
    270277
Note: See TracChangeset for help on using the changeset viewer.