Bug 7296 - Make sa-learn handle folder list prefixes with blank types
Summary: Make sa-learn handle folder list prefixes with blank types
Alias: None
Product: Spamassassin
Classification: Unclassified
Component: Learner (show other bugs)
Version: SVN Trunk (Latest Devel Version)
Hardware: PC Linux
: P2 normal
Target Milestone: Undefined
Assignee: SpamAssassin Developer Mailing List
Depends on:
Reported: 2016-02-05 21:28 UTC by John Brooks
Modified: 2017-08-07 16:05 UTC (History)
1 user (show)

Attachment Type Modified Status Actions Submitter/CLA Status
Patch patch None John Brooks [HasCLA]
Patch generated with svn diff patch None John Brooks [HasCLA]

Note You need to log in before you can comment on or make changes to this bug.
Description John Brooks 2016-02-05 21:28:46 UTC
Created attachment 5378 [details]

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:

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.