On Fri, 2009-04-03 at 14:18 -0700, Artur Bergman wrote: > Global is better than none.
Attached. In writing it, I went to document the new config option, and noticed that there doesn't seem to be any POD about known config options. Would lib/DJabberd/Config.pod be the right place? - Alex
>From 535480246809af9a1005ce355aa98a982bf18e02 Mon Sep 17 00:00:00 2001 From: Alex Vandiver <ale...@mit.edu> Date: Fri, 3 Apr 2009 17:47:36 -0400 Subject: [PATCH] Add global CaseSensitive flag for backwards compatibility --- DJabberd/lib/DJabberd.pm | 5 +++++ DJabberd/lib/DJabberd/JID.pm | 7 +++++++ 2 files changed, 12 insertions(+), 0 deletions(-) diff --git a/DJabberd/lib/DJabberd.pm b/DJabberd/lib/DJabberd.pm index 9debd3d..a168fdb 100644 --- a/DJabberd/lib/DJabberd.pm +++ b/DJabberd/lib/DJabberd.pm @@ -167,6 +167,11 @@ sub fake_s2s_peer { return $fake_peers{$host}; } +sub set_config_casesensitive { + my ($self, $val) = @_; + $DJabberd::JID::CASE_SENSITIVE = as_bool($val); +} + sub add_vhost { my ($self, $vhost) = @_; my $sname = lc $vhost->name; diff --git a/DJabberd/lib/DJabberd/JID.pm b/DJabberd/lib/DJabberd/JID.pm index b644742..bf9a80b 100644 --- a/DJabberd/lib/DJabberd/JID.pm +++ b/DJabberd/lib/DJabberd/JID.pm @@ -3,6 +3,9 @@ use strict; use DJabberd::Util qw(exml); use Digest::SHA1; +# Configurable via 'CaseSensitive' config option +our $CASE_SENSITIVE = 0; + use overload '""' => \&as_string_exml; @@ -108,6 +111,10 @@ sub new { (?: /(.{1,1023}) )? # $3: optional resource $!x; + # If we're in case-sensitive mode, for backwards-compatibility, + # then skip stringprep + return bless [ $1, $2, $3 ], $_[0] if $DJabberd::JID::CASE_SENSITIVE; + # Stringprep uses regexes, so store these away first my ($node, $host, $res) = ($1, $2, $3); -- 1.6.2.1.321.g7b198.dirty