Repository: sopel-irc/sopel

Issue:
[url] meaning of `exclude` changed?
i used to have the following in my `sopel.cfg`:

``` ini
[url]
exclude =
exclusion_char = !
```

... and it worked fine up to (and including) 6.1.1. After an upgrade to 6.3.0, the bot was silent on `.title http://example.com/`, all of a sudden - the above`exclude` pattern would match everything!

after removing the above block, the proper `.title` behavior was restored. the problem is the above is the default config generated when you run `sopel -w`: so by default, now, it seems that the url plugin config is basically broken and there's no way to configure the bot to _not_ be silent (unless you input an impossible regex) by default.

[url] 'function' object has no attribute 'priority'
Sopel v. 6.5.0 is not loading the `url` module properly. I am unable to get titles using `.title http://url.here`, and reloading the module gives this error:

````
<dgw> Sopel: reload url
<Sopel> AttributeError: 'function' object has no attribute 'priority' (file
        "/usr/local/lib/python2.7/dist-packages/sopel/bot.py", line 213, in unregister)
````

Perhaps that's a red herring, because on startup Sopel prints to stdout: `Error in url setup procedure: nothing to repeat (../../../../../lib/python2.7/re.py:242)`

My config includes no `exclude` rules, and `exclusion_char = ^`. This occurs both with an empty `exclude` option in the config file and with no `exclude` line at all.


Discussion:
Spent some time working on this. Apparently this config section:

``` ini
[url]
exclude = 
exclusion_char = ^
```

causes the URL exclusions list to contain a single empty string, which `setup()` tries to compile. In debugging different pieces of the module I've variously caused the module to spit out an error, fail to load, and even crash the whole bot on reload. At any rate, a regex with the pattern `''` will match any URL, which effectively makes it exclude any link, which is bad.

What I haven't been able to do is cleanly prevent `url.setup()` from compiling `''` as an exclusion regex. One would think that tweaking the relevant part of `setup` to read:

``` python
    if bot.config.url.exclude:
        regexes = [re.compile(s) for s in bot.config.url.exclude if s]
```

would prevent it, because `''` evaluates to `False` in conditionals. I also tried `if s != ''`, with no luck. I even did some interactive console investigations to confirm that, and it does what it should in a trivial Python console example:

```
>>> import re
>>> r = ['']
>>> len(r)
1
>>> len([re.compile(s) for s in r if s])
0
```

But if I did things I shouldn't do and used `bot.say()` in `setup()` to print out `' '.join([hex(ord(c)) for c in s])` for each exclusion rule during module reload, it said simply `<sopel> excluded url pattern:`, the lack of any hex character codes confirming that it is indeed the empty string `''`. Which shouldn't be compiled with the code change above, but it is.

I eventually had to give up simply due to fatigue (I did this last night, after midnight). It's just strange, something that seems from all accounts like it _should_ work, not working.

NB: Still present in 6.5.1.

Resolving patch:
diff --git a/sopel/config/types.py b/sopel/config/types.py
--- a/sopel/config/types.py
+++ b/sopel/config/types.py
@@ -222,7 +222,7 @@ def __init__(self, name, strip=True, default=None):
         self.strip = strip
 
     def parse(self, value):
-        value = value.split(',')
+        value = list(filter(None, value.split(',')))
         if self.strip:
             return [v.strip() for v in value]
         else:


Test patch: