You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by jm...@apache.org on 2004/02/08 01:45:28 UTC

svn commit: rev 6572 - incubator/spamassassin/trunk/lib/Mail/SpamAssassin

Author: jm
Date: Sat Feb  7 16:45:27 2004
New Revision: 6572

Modified:
   incubator/spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm
Log:
added relative-path support to loadplugin

Modified: incubator/spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm
==============================================================================
--- incubator/spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm	(original)
+++ incubator/spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm	Sat Feb  7 16:45:27 2004
@@ -100,6 +100,7 @@
 package Mail::SpamAssassin::Conf;
 use Mail::SpamAssassin::Util;
 use Mail::SpamAssassin::NetSet;
+use File::Spec;
 
 use strict;
 use bytes;
@@ -2602,8 +2603,10 @@
 =item loadplugin PluginModuleName /path/to/module.pm
 
 Load a SpamAssassin plugin module.  The C<PluginModuleName> is the perl module
-name, used to create the plugin object itself; C</path/to/module.pm> is the
-file to load, containing the module's perl code.
+name, used to create the plugin object itself.  C</path/to/module.pm> is the
+file to load, containing the module's perl code; if it's specified as a
+relative path, it's considered to be relative to the current configuration
+file.
 
 See C<Mail::SpamAssassin::Plugin> for more details on writing plugins.
 
@@ -2611,7 +2614,15 @@
 
     # leave as RE right now
     if (/^loadplugin\s+(\S+)\s+(\S+)$/) {
-      $self->load_plugin ($1, $2); next;
+      my $mod = $1;
+      my $path = $2;
+
+      if (!File::Spec->file_name_is_absolute ($path)) {
+	my ($vol, $dirs, $file) = File::Spec->splitpath ($self->{currentfile});
+	$path = File::Spec->catpath ($vol, $dirs, $path);
+	dbg ("loadplugin: fixed relative path: $path");
+      }
+      $self->load_plugin ($mod, $path); next;
     }
 
 ###########################################################################