Adding a regex filter makes pi-hole services non-functional

Expected Behaviour:

A regex-based blacklist will block more ads.

Note: I was using the FTL-branch but switched to v4.0 to see if that would resolve the issue - it did not.

Actual Behaviour:

Adding a regex value to the blacklist causes both the pi-hole and pi-hole-FTL services to stop functioning entirely.

ex.

*analytics* or ads.*

through the Web GUI.

Debug Token:

It will not upload while these settings are in place unfortunately. I have a local copy of the log if someone could point me to the most convenient place for them to view it!

What regex strings are you trying to add? Have a look at Redirecting... to see what valid regex is required for proper operation.

1 Like

That tutorial must be new!

The exact regex strings I was trying to add were:

*analytics*
ads.*

which are valid regex strings as far as I know.

*analytics* isn't valid. The leading * has nothing to quantify, and it's not matching what you may think. Without the invalid leading *, analytics* would mean match the characters a followed by n ... followed by c and ending with zero or more s chars.

Try https://regex101.com and use some of your regex values and you'll see the errors that they produce and what they actually match against.

You are completely right - I took those from a blocklist and assumed they were valid regex expressions.

That said, if an invalid string is entered, the services do stop functioning entirely. Perhaps a check within pi-hole to determine if the regex string is valid before adding it to the list would be a viable solution?

Thanks for the input. We can see about validating regex, it's such a fickle beast it becomes more of an issue to validate. We could check for a pass/fail condition with the regex string and at least return an invalid message. But parsing the validity and reporting to users what exactly is invalid would be quite the undertaking when there are so many other projects and tools to give you a better experience with testing and creating the regex values and strings. We'll take a look though and see what provides the best user experience.

1 Like

I believe a pass/fail would be more than enough to alert users that they are doing something incorrectly, as nothing appears wrong until the device is rebooted or those services are restarted. Thank you for your time!

If this is the case, it is a bug. FTL does ignore invalid regex filters and print a warning in its log file. Try again with the invalid string you had before and post the last messages in /var/log/pihole-FTL.log.

You may also want to try to enable the regex debugging mode (it is only available in the most recent beta version).


PS You are right, we have a bug in the error logging routine. It will be fixed in

https://github.com/pi-hole/FTL/pull/337

FTL will now log:

[2018-08-05 14:24:03.272] ERROR compiling regex on line 20: Invalid preceding regular expression (13)

where on line 20 I added your invalid *analytics* regex string.

Thanks for pointing out this bug!

2 Likes

Thank you so much!

This fix is included in the Pi-hole v4.0 release.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.