Fix #1517 - escape regexp special chars before adding autorec rule.
This stops autorec rules entered from event failing to detect events.
This commit is contained in:
parent
87822f001f
commit
97c739b572
3 changed files with 40 additions and 1 deletions
|
@ -559,9 +559,11 @@ void dvr_autorec_add_series_link
|
|||
( const char *dvr_config_name, epg_broadcast_t *event,
|
||||
const char *creator, const char *comment )
|
||||
{
|
||||
char *title;
|
||||
if (!event || !event->episode) return;
|
||||
title = regexp_escape(epg_broadcast_get_title(event, NULL));
|
||||
_dvr_autorec_add(dvr_config_name,
|
||||
epg_broadcast_get_title(event, NULL),
|
||||
title,
|
||||
event->channel,
|
||||
NULL, 0, // tag/content type
|
||||
NULL,
|
||||
|
@ -569,6 +571,8 @@ void dvr_autorec_add_series_link
|
|||
event->serieslink,
|
||||
0, NULL,
|
||||
creator, comment);
|
||||
if (title)
|
||||
free(title);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -561,6 +561,8 @@ int makedirs ( const char *path, int mode );
|
|||
|
||||
int rmtree ( const char *path );
|
||||
|
||||
char *regexp_escape ( const char *str );
|
||||
|
||||
/* printing */
|
||||
#if __SIZEOF_LONG__ == 8
|
||||
#define PRItime_t PRId64
|
||||
|
|
33
src/utils.c
33
src/utils.c
|
@ -403,3 +403,36 @@ rmtree ( const char *path )
|
|||
err = rmdir(path);
|
||||
return err;
|
||||
}
|
||||
|
||||
char *
|
||||
regexp_escape(const char* str)
|
||||
{
|
||||
const char *a;
|
||||
char *tmp, *b;
|
||||
if (!str)
|
||||
return NULL;
|
||||
a = str;
|
||||
b = tmp = malloc(strlen(str) * 2);
|
||||
while (*a) {
|
||||
switch (*a) {
|
||||
case '?':
|
||||
case '+':
|
||||
case '.':
|
||||
case '(':
|
||||
case ')':
|
||||
case '[':
|
||||
case ']':
|
||||
case '*':
|
||||
*b = '\\';
|
||||
b++;
|
||||
/* -fallthrough */
|
||||
default:
|
||||
break;
|
||||
}
|
||||
*b = *a;
|
||||
b++;
|
||||
a++;
|
||||
}
|
||||
*b = 0;
|
||||
return tmp;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue