[Koha-patches] [PATCH] Fixed bug 3068 - tightenn regex for ip matching

Walls, Ian Ian.Walls at med.nyu.edu
Wed Sep 16 17:04:09 CEST 2009


Patch resubmitted with regex properly escaped
---
 C4/Auth.pm                                         |    5 +++++
 .../prog/en/modules/help/admin/branches.tmpl       |    3 ++-
 2 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/C4/Auth.pm b/C4/Auth.pm
index afe5fbf..37c8134 100644
--- a/C4/Auth.pm
+++ b/C4/Auth.pm
@@ -680,6 +680,9 @@ sub checkauth {
                     if (C4::Context->boolean_preference('IndependantBranches') && C4::Context->boolean_preference('Autolocation')){
                         # we have to check they are coming from the right ip range
                         my $domain = $branches->{$branchcode}->{'branchip'};
+			# escape '.' and replace '*' with \d{1-3}
+			$domain =~ s/\./\\./g;
+			$domain =~ s/\*/\\d{1-3}/g;
                         if ($ip !~ /^$domain/){
                             $loggedin=0;
                             $info{'wrongip'} = 1;
@@ -690,6 +693,8 @@ sub checkauth {
                     foreach my $br ( keys %$branches ) {
                         #     now we work with the treatment of ip
                         my $domain = $branches->{$br}->{'branchip'};
+			$domain =~ s/\./\\./g;
+			$domain =~ s/\*/\\d{1-3}/g;
                         if ( $domain && $ip =~ /^$domain/ ) {
                             $branchcode = $branches->{$br}->{'branchcode'};
 
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/help/admin/branches.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/help/admin/branches.tmpl
index bf397d0..85a7d6a 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/help/admin/branches.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/help/admin/branches.tmpl
@@ -4,4 +4,5 @@
 
 <p>Fill in information about your library service outlets on this page.</p>
 <p>Begin by defining your branch categories. If, for example, you have one main library and several branch libraries, you might set up an &quot;M&quot; (Main) category and a &quot;B&quot; (Branch) category, with descriptions &quot;Main Library&quot; and &quot;Branch Library.&quot;</p>
-<p>Now add the names and addresses, phone numbers, etc of your libraries in the &quot;Branches&quot; section. (All of your libraries should be described here, not just the branch libraries.) Give each library a unique and easily-remembered code (maximum of four characters). This code will be used in Koha's database to identify each library. When libraries are listed in Koha, they will be listed in alphabetical order by code.</p><!-- TMPL_INCLUDE NAME="help-bottom.inc" -->
\ No newline at end of file
+<p>Now add the names and addresses, phone numbers, etc of your libraries in the &quot;Branches&quot; section. (All of your libraries should be described here, not just the branch libraries.) Give each library a unique and easily-remembered code (maximum of four characters). This code will be used in Koha's database to identify each library. When libraries are listed in Koha, they will be listed in alphabetical order by code.</p>
+<p>An IP address or range can be specified for a Branch; use '*' to indicate a wildcard in any octet.</p><!-- TMPL_INCLUDE NAME="help-bottom.inc" -->
-- 
1.5.4.3


------------------------------------------------------------
This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain information that is proprietary, confidential, and exempt from disclosure under applicable law. Any unauthorized review, use, disclosure, or distribution is prohibited. If you have received this email in error please notify the sender by return email and delete the original message. Please note, the recipient should check this email and any attachments for the presence of viruses. The organization accepts no liability for any damage caused by any virus transmitted by this email.
=================================




More information about the Koha-patches mailing list