Changeset cc27237
- Timestamp:
- Jan 7, 2014, 6:02:25 PM (9 years ago)
- Children:
- 611236e
- Parents:
- 4b9c3b9
- git-author:
- Jason Gross <jgross@mit.edu> (01/01/14 20:59:51)
- git-committer:
- Jason Gross <jgross@mit.edu> (01/07/14 18:02:25)
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
perl/lib/BarnOwl/Message/Zephyr.pm
r50a3240 rcc27237 9 9 10 10 use base qw( BarnOwl::Message ); 11 use Unicode::Normalize qw( NFKC );12 11 13 12 sub strip_realm { … … 22 21 my ($user, $realm) = split(/@/,$principal); 23 22 return $realm; 23 } 24 25 sub 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); 24 31 } 25 32 … … 261 268 my $realm = ''; 262 269 $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)); 264 271 } 265 272 } else { 266 273 push @filenames, $m->recipient; 267 274 } 268 return map { lc(NFKC(BarnOwl::zephyr_smartstrip_user(strip_realm($_)))) } @filenames;275 return map { casefold_principal(BarnOwl::zephyr_smartstrip_user(strip_realm($_))) } @filenames; 269 276 } 270 277 -
perl/modules/Jabber/lib/BarnOwl/Message/Jabber.pm
rdca6255 rcc27237 15 15 16 16 use base qw( BarnOwl::Message ); 17 use Unicode::Normalize qw( NFKC );18 17 19 18 sub jtype { shift->{jtype} }; … … 174 173 175 174 sub log_filenames { 176 return map { lc(NFKC($_)) } BarnOwl::Message::log_filenames(@_);175 return map { BarnOwl::compat_casefold($_) } BarnOwl::Message::log_filenames(@_); 177 176 } 178 177 -
perlglue.xs
r6e764aa rcc27237 385 385 RETVAL 386 386 387 const utf8 * 388 compat_casefold(in) 389 const char * in 390 PREINIT: 391 char *rv; 392 CODE: 393 rv = owl_util_compat_casefold(in); 394 RETVAL = rv; 395 OUTPUT: 396 RETVAL 397 CLEANUP: 398 g_free(rv); 399 387 400 388 401 MODULE = BarnOwl PACKAGE = BarnOwl::Zephyr -
util.c
r7b89e8c rcc27237 640 640 } 641 641 642 CALLER_OWN char *owl_util_compat_casefold(const char *str) 643 { 644 /* 645 * Quoting Anders Kaseorg at https://github.com/barnowl/barnowl/pull/54#issuecomment-31452543: 646 * 647 * The Unicode specification calls this compatibility caseless matching, and 648 * the correct transformation actually has five calls: 649 * NFKC(toCasefold(NFKD(toCasefold(NFD(string))))) Zephyr’s current 650 * implementation incorrectly omits the innermost NFD, but that difference 651 * only matters for characters including U+0345 ◌ͅ COMBINING GREEK 652 * YPOGEGRAMMENI. I think we should just write the correct version and get 653 * Zephyr fixed. 654 * 655 * Neither of these operations should be called toNFKC_Casefold, because that 656 * has slightly different behavior regarding Default_Ignorable_Code_Point. I 657 * propose compat_casefold. And I guess if Jabber wants it too, we should 658 * move it to util.c. 659 */ 660 char *tmp0 = g_utf8_normalize(str, -1, G_NORMALIZE_NFD); 661 char *tmp1 = g_utf8_casefold(tmp0, -1); 662 char *tmp2 = g_utf8_normalize(tmp1, -1, G_NORMALIZE_NFKD); 663 char *tmp3 = g_utf8_casefold(tmp2, -1); 664 char *out = g_utf8_normalize(tmp3, -1, G_NORMALIZE_NFKC); 665 g_free(tmp0); 666 g_free(tmp1); 667 g_free(tmp2); 668 g_free(tmp3); 669 670 return out; 671 } 672 642 673 /* This is based on _extract() and _isCJ() from perl's Text::WrapI18N */ 643 674 int owl_util_can_break_after(gunichar c)
Note: See TracChangeset
for help on using the changeset viewer.