Bug 7296

Summary: Make sa-learn handle folder list prefixes with blank types
Product: Spamassassin Reporter: John Brooks <john>
Component: LearnerAssignee: SpamAssassin Developer Mailing List <dev>
Status: RESOLVED FIXED    
Severity: normal CC: john
Priority: P2    
Version: SVN Trunk (Latest Devel Version)   
Target Milestone: Undefined   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments: Patch
Patch generated with svn diff

Description John Brooks 2016-02-05 21:28:46 UTC
Created attachment 5378 [details]
Patch

When given a folder list with the -f option, sa-learn does not currently handle prefixes that do not specify a type. For example, given this line:
ham::/path/to/ham

sa-learn will throw this error:
archive-iterator: unable to open ham::/path/to/ham: No such file or directory

This is because ArchiveIterator expects a format to be specified, and sa-learn is supposed to pass "detect" by default if one is not specified. This was not happening when sa-learn was given a folder list with unspecified formats.

I have attached a patch to make sa-learn ensure that the format field is filled upon reading in the folder list.
Comment 1 John Brooks 2016-02-05 21:40:41 UTC
To clarify, because sa-learn did not put "detect" into the string when reading the folder list, sa-learn later tries to "fix" the improperly formatted target string by running it through a subroutine (target()) which is only meant to be used on bare paths, and not prefixed folder list entries.
Comment 2 John Brooks 2016-03-08 18:14:42 UTC
It's been a month, is anyone going to look at this?
Comment 3 John Brooks 2017-02-08 01:12:48 UTC
Anyone want to look at this for the upcoming minor release?
Comment 4 John Brooks 2017-07-26 18:05:34 UTC
Created attachment 5458 [details]
Patch generated with svn diff

Regenerated the patch with svn diff instead of git format-patch
Comment 5 Karsten Bräckelmann 2017-08-07 16:05:22 UTC
Thanks for the report, John. Indeed, sa-learn happily accepted an empty type argument in the --folders option, but failed to rewrite it to "detect". According to the documentation, sa-learn promises to accept an empty type, while the ArchiveIterator expects the "detect" type to be given explicitly.

Fixed in trunk and stable 3.4 branch respectively:

Sending        sa-learn.raw
Committed revision 1804345.

Sending        sa-learn.raw
Committed revision 1804346.

Closing RESOLVED FIXED.