Docker_isbg

I recently started using docker_isbg, a container bundling isbg and imapfilter to filter out spam from a remote IMAP server.

Getting started is relatively straightforward and relies mostly on a JSON configuration file such as

{
  "server": "mail.somewhere.com",
  "username": "somebody@somewhere.com",
  "password": "Password",
  "isGmail": "no",                        //Optional; Default = no
  "spamSubject": "[SPAM?]",               //Optional;
  "report": "yes",                        //Optional; Default = no
  "spamLifetime": 30,                     //Optional;
  "folders": {
    "spam": "Spam",
    "ham": "ham",                         //Optional;
    "sent": "Sent",                       //Optional;
    "inbox": "INBOX"
  }
}

After setting it up to run on a non-Gmail email host, however, I noticed the logs were complaining that isbg couldn’t find Gmail-specific folders. That meant that, somehow, my configuration was telling isbg that I was on a gmail host, even though the line"isGmail": "no" was in my config.

After some looking around, I saw the offending piece of code in docker_isbg (newlines added for clarity):

if( confLoader.tableHasKey( config, "isGmail" ) 
    and config.isGmail ) 
    then 
      gmailOption = " --gmail" 
    else 
      gmailOption = "" end 

The code checks whether config (which is a dictionary-like object resulting from the parsing of the above JSON) has a isGmail key, and whether it is set to anything: it can be yes, no or any other string and it will pass the --gmail option to isbg.

To fix it, I opened a PR that changes the above lines to

if( confLoader.tableHasKey( config, "isGmail" ) 
    and config.isGmail == "yes" ) 
    then 
      gmailOption = " --gmail" 
    else 
      gmailOption = "" end 

While the project seems to be mostly abandoned so I don’t expect a prompt merge, there’s another easy fix: changing the "isGmail": "no", line to "isGmail": false in the configuration file as in that case the config.isGmail code will evaluate to false.