Bug 1491 - ~/ replacement in ArchiveIterator?
Summary: ~/ replacement in ArchiveIterator?
Status: RESOLVED FIXED
Alias: None
Product: Spamassassin
Classification: Unclassified
Component: Libraries (show other bugs)
Version: SVN Trunk (Latest Devel Version)
Hardware: Other other
: P5 normal
Target Milestone: 2.50
Assignee: SpamAssassin Developer Mailing List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-02-17 00:47 UTC by Daniel Quinlan
Modified: 2003-02-16 22:00 UTC (History)
0 users



Attachment Type Modified Status Actions Submitter/CLA Status

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Quinlan 2003-02-17 00:47:39 UTC
Shouldn't there be an ^ in there?

Sorry, cut-and-pasted diff, but this one is easy.

diff -u -r1.27 ArchiveIterator.pm
--- lib/Mail/SpamAssassin/ArchiveIterator.pm    1 Feb 2003 17:06:33 -0000       1.27
+++ lib/Mail/SpamAssassin/ArchiveIterator.pm    17 Feb 2003 08:46:32 -0000
@@ -437,7 +437,7 @@
   my ($self, $path) = @_;
 
   # fix home dir: ~ = /home/jm
-  $path =~ s/\~/$ENV{'HOME'}/g;
+  $path =~ s/^\~/$ENV{'HOME'}/;
 
   # fix csh-style globs: * = er, you know what it does ;)
   my @paths = glob $path;
Comment 1 Malte S. Stretz 2003-02-17 02:56:15 UTC
At least can't I see any reason to replace every tilde in the path with $HOME.  
I changed it and also added escaping for white spaces in paths (most of my  
folders contain white spaces).  
Comment 2 Daniel Quinlan 2003-02-17 04:09:21 UTC
Malte, I think you missed my point: code review, being circumspect about
making changes during freeze, etc.

Anyway, just note that the current escaping code doesn't handle odd cases
like backslashed backslashes (handling spaces is a higher priority).

I do, however, like the slightly more elegant:

  s/(?<!\\)(\s)/\\$1/g;

Yeah, I'm showing off, but you asked for it.  Hmmm... or did I ask for it
by not assigning the bug to myself?  Whatever... :-)

- Dan
Comment 3 Malte S. Stretz 2003-02-17 05:45:21 UTC
Got the point, but do you think code review is really important in thise 
obvious case? I can't see _any_ good reason to have ~/Mail/Almost~There 
replaced with /home/mss/Mail/Almosthome/mssThere. ;-) 
 
For the escaping, I first wanted to use the look-behind RE but then I faintly 
remembered something about problems with either look-behind or look-ahead in 
Perl 5.005. It was either not implemented or very expensive. As I did not want 
to grep through the old docs, I took the unelegant way. Oh, and whoever wants 
to use backslashes in front of spaces in his paths should maybe think about 
his naming scheme :o) 
Comment 4 Antony Mawer 2003-02-17 06:05:25 UTC
Subject: Re: [SAdev]  ~/ replacement in ArchiveIterator? 


I'm a little worried about the 'escaping spaces' change.  What's the
purpose of it?  Surely perl does not care if the spaces are escaped in
paths used internally, and in the mass-check output, spaces are replaced
by underscores anyway.

Does the glob function require that spaces be escaped?   (in that case
the change makes sense.)

BTW I've just tested with a space-containing dir, and "mass-check" seems
to work OK with it, mind you -- so it *seems* good.  I'm just paranoid
at this late stage!

--j.

Comment 5 Daniel Quinlan 2003-02-17 06:22:11 UTC
Subject: Re:  ~/ replacement in ArchiveIterator?

> I'm a little worried about the 'escaping spaces' change.  What's the
> purpose of it?  Surely perl does not care if the spaces are escaped in
> paths used internally, and in the mass-check output, spaces are replaced
> by underscores anyway.
>
> Does the glob function require that spaces be escaped?   (in that case
> the change makes sense.)

Yeah, that's basically why I gave Malte a bit of a hard time.  I had to
look into the change to understand why it was necessary, so it was (in
my book), a big enough of a change to require a bit more explanation and
review during our freeze.

Incidentally, I've been using the tilde change for several weeks (on the
back burner, so to speak), so I wasn't too worried about it, but I did
want to run it by someone else (which I did).

Anyway, yes, "glob" evidently requires that spaces be escaped.  News to
me too.

- Dan

Comment 6 Malte S. Stretz 2003-02-17 07:00:14 UTC
File::Glob globs like the shell does: Spaces separate files. So an entry like 
  spam:mbox:~/.Mail/My Spam 
will make mass-check look for the files "~/Mail/My" and "Spam". 
 
Somebody checked in the glob code shortly before the big mass-check and I just 
started my check overnight, discovering the next morning that all I got was an 
error complainig about a missing dir. That's why I went and fixed this one (I 
got the RE already in my copy of the ArchiveIterator) because I was pretty 
pissed back then. 
Comment 7 Antony Mawer 2003-02-17 07:35:49 UTC
Subject: Re: [SAdev]  ~/ replacement in ArchiveIterator? 


> ------- Additional Comments From ajmawer@optusnet.com.au

oh FFS. ;) That's jm@jmason.org BTW.

Comment 8 Daniel Quinlan 2003-02-17 16:50:41 UTC
Subject: Re:  ~/ replacement in ArchiveIterator?

ajmawer@optusnet.com.au writes:

> oh FFS. ;) That's jm@jmason.org BTW.

I've been wondering about that, but hadn't quite brought myself to ask
if it was really you.

- Dan