Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new config flag REGEX_IGNORECASE #620

Merged
merged 2 commits into from
Jul 18, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,19 @@ void read_FTLconf(void)
else
logg(" PARSE_ARP_CACHE: Inactive");

// REGEX_IGNORECASE
// defaults to: No
AzureMarker marked this conversation as resolved.
Show resolved Hide resolved
config.regex_ignorecase = false;
buffer = parse_FTLconf(fp, "REGEX_IGNORECASE");

if(buffer != NULL && strcasecmp(buffer, "true") == 0)
config.regex_ignorecase = true;

if(config.regex_ignorecase)
logg(" REGEX_IGNORECASE: Enabled. Regex is case insensitive");
else
logg(" REGEX_IGNORECASE: Disabled. Regex is case sensitive");

// Read DEBUG_... setting from pihole-FTL.conf
read_debuging_settings(fp);

Expand Down
1 change: 1 addition & 0 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ typedef struct {
bool analyze_only_A_AAAA;
bool DBimport;
bool parse_arp_cache;
bool regex_ignorecase;
} ConfigStruct;

typedef struct {
Expand Down
5 changes: 4 additions & 1 deletion src/regex.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ static bool init_regex(const char *regexin, const int index)
{
// compile regular expressions into data structures that
// can be used with regexec to match against a string
const int errcode = regcomp(&regex[index], regexin, REG_EXTENDED);
int regflags = REG_EXTENDED;
if(config.regex_ignorecase)
regflags |= REG_ICASE;
const int errcode = regcomp(&regex[index], regexin, regflags);
if(errcode != 0)
{
log_regex_error("compiling", errcode, index);
Expand Down